@itwin/hypermodeling-frontend 5.0.0-dev.55 → 5.0.0-dev.57
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.
- package/lib/cjs/HyperModeling.js +5 -2
- package/lib/cjs/HyperModeling.js.map +1 -1
- package/lib/cjs/HyperModelingDecorator.js +18 -6
- package/lib/cjs/HyperModelingDecorator.js.map +1 -1
- package/lib/cjs/PopupToolbar.js +6 -4
- package/lib/cjs/PopupToolbar.js.map +1 -1
- package/lib/cjs/SectionDrawingLocationState.js +28 -0
- package/lib/cjs/SectionDrawingLocationState.js.map +1 -1
- package/lib/cjs/SectionGraphicsProvider.js +8 -0
- package/lib/cjs/SectionGraphicsProvider.js.map +1 -1
- package/lib/cjs/SectionMarkers.js +11 -7
- package/lib/cjs/SectionMarkers.js.map +1 -1
- package/lib/cjs/Tools.js +4 -4
- package/lib/cjs/Tools.js.map +1 -1
- package/lib/esm/HyperModeling.js +5 -2
- package/lib/esm/HyperModeling.js.map +1 -1
- package/lib/esm/HyperModelingDecorator.js +18 -6
- package/lib/esm/HyperModelingDecorator.js.map +1 -1
- package/lib/esm/PopupToolbar.js +6 -4
- package/lib/esm/PopupToolbar.js.map +1 -1
- package/lib/esm/SectionDrawingLocationState.js +28 -0
- package/lib/esm/SectionDrawingLocationState.js.map +1 -1
- package/lib/esm/SectionGraphicsProvider.js +8 -0
- package/lib/esm/SectionGraphicsProvider.js.map +1 -1
- package/lib/esm/SectionMarkers.js +11 -7
- package/lib/esm/SectionMarkers.js.map +1 -1
- package/lib/esm/Tools.js +4 -4
- package/lib/esm/Tools.js.map +1 -1
- package/package.json +12 -12
|
@@ -21,6 +21,16 @@ const markerSize = core_geometry_1.Point2d.create(40, 40);
|
|
|
21
21
|
* @public
|
|
22
22
|
*/
|
|
23
23
|
class SectionMarker extends core_frontend_1.Marker {
|
|
24
|
+
/** The section drawing location state associated with the marker. */
|
|
25
|
+
state;
|
|
26
|
+
/** A description displayed as part of the tooltip when this marker is clustered with other markers. */
|
|
27
|
+
description;
|
|
28
|
+
/** @internal */
|
|
29
|
+
onMouseEnterEvent = new core_bentley_1.BeEvent();
|
|
30
|
+
/** @internal */
|
|
31
|
+
onMouseButtonEvent = new core_bentley_1.BeEvent();
|
|
32
|
+
/** @internal */
|
|
33
|
+
_isActive = false;
|
|
24
34
|
/** Constructor, typically invoked indirectly via [[HyperModelingDecorator]].
|
|
25
35
|
* @param state The section drawing location state this marker will represent.
|
|
26
36
|
* @param pos The world coordinates at which to display the marker.
|
|
@@ -30,12 +40,6 @@ class SectionMarker extends core_frontend_1.Marker {
|
|
|
30
40
|
*/
|
|
31
41
|
constructor(state) {
|
|
32
42
|
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
43
|
this.state = state;
|
|
40
44
|
const data = HyperModeling_1.HyperModeling.getMarkerData(state.sectionType);
|
|
41
45
|
this.description = data.label;
|
|
@@ -141,6 +145,7 @@ exports.SectionMarkerCluster = SectionMarkerCluster;
|
|
|
141
145
|
* @public
|
|
142
146
|
*/
|
|
143
147
|
class SectionMarkerSet extends core_frontend_1.MarkerSet {
|
|
148
|
+
minimumClusterSize = 5;
|
|
144
149
|
/** Constructor
|
|
145
150
|
* @param viewport The viewport in which the markers are to be displayed.
|
|
146
151
|
* @param markers The markers to be displayed.
|
|
@@ -148,7 +153,6 @@ class SectionMarkerSet extends core_frontend_1.MarkerSet {
|
|
|
148
153
|
*/
|
|
149
154
|
constructor(viewport, markers) {
|
|
150
155
|
super(viewport);
|
|
151
|
-
this.minimumClusterSize = 5;
|
|
152
156
|
for (const marker of markers) {
|
|
153
157
|
if (marker.state.iModel === viewport.iModel)
|
|
154
158
|
this.markers.add(marker);
|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QAC1B,IAAA,qBAAM,EAAC,SAAS,KAAK,KAAK,CAAC,QAAQ,CAAC,CAAC;QACrC,OAAO,KAAK,CAAC,QAAQ,CAAC;IACxB,CAAC;IAED,gBAAgB;IACN,gBAAgB,CAAC,OAA+B;QACxD,OAAO,IAAI,oBAAoB,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC5H,CAAC;IAED,mGAAmG;IAC5F,cAAc,CAAC,wBAAoC;QACxD,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO;YAC/B,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,wBAAwB;gBAC9C,OAAO,MAAM,CAAC;QAElB,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAnCD,4CAmCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module HyperModeling\n */\n\nimport { assert, BeEvent, Id64String } from \"@itwin/core-bentley\";\nimport { Point2d, Point3d, XAndY, XYAndZ } from \"@itwin/core-geometry\";\nimport { IModelReadRpcInterface } from \"@itwin/core-common\";\nimport {\n BeButton, BeButtonEvent, Cluster, DecorateContext, IModelApp, InputSource, Marker, MarkerImage, MarkerSet, ScreenViewport, ViewClipTool,\n} from \"@itwin/core-frontend\";\nimport { SectionDrawingLocationState } from \"./SectionDrawingLocationState\";\nimport { HyperModeling } from \"./HyperModeling\";\n\nconst markerSize = Point2d.create(40, 40);\n\n/** A [Marker]($frontend) associated with a [[SectionDrawingLocationState]], displayed as a canvas decoration at the location of the section.\n * Clicking on the marker toggles display of the section graphics. Mousing over the marker produces a toolbar with additional interactions.\n * @see [[HyperModelingDecorator]] for a [Decorator]($frontend) capable of displaying section markers for each section drawing location.\n * @see [[SectionMarkerHandler]] to customize the marker interactions.\n * @public\n */\nexport class SectionMarker extends Marker {\n /** The section drawing location state associated with the marker. */\n public readonly state: SectionDrawingLocationState;\n /** A description displayed as part of the tooltip when this marker is clustered with other markers. */\n public readonly description: string;\n /** @internal */\n public readonly onMouseEnterEvent = new BeEvent<(marker: SectionMarker) => void>();\n /** @internal */\n public readonly onMouseButtonEvent = new BeEvent<(marker: SectionMarker) => void>();\n /** @internal */\n private _isActive = false;\n\n /** Constructor, typically invoked indirectly via [[HyperModelingDecorator]].\n * @param state The section drawing location state this marker will represent.\n * @param pos The world coordinates at which to display the marker.\n * @param description A brief description of this marker, used as part of the tooltip when this marker is part of a cluster.\n * @param icon The icon displayed by the marker.\n * @param tooltip Optional detailed tooltip displayed on mouse hover. If undefined, the `description` is used instead.\n */\n public constructor(state: SectionDrawingLocationState) {\n super(state.placement.origin.clone(), markerSize);\n this.state = state;\n\n const data = HyperModeling.getMarkerData(state.sectionType);\n this.description = data.label;\n if (data.image)\n this.setImage(data.image);\n\n this.setScaleFactor({ low: .2, high: 1.4 }); // make size 20% at back of frustum and 140% at front of frustum (if camera is on)\n }\n\n /** @internal */\n public get isHilited(): boolean { return this._isHilited; }\n\n /** Returns true if this is the \"active\" section marker. At most one marker is active at a given time.\n * @see [[HyperModelingDecorator.activeMarker]].\n * @see [[HyperModelingDecorator.setActiveMarker]].\n * @see [[SectionMarkerHandler.toggleMarker]].\n */\n public get isActive(): boolean {\n return this._isActive;\n }\n\n /** @internal */\n public setActive(active: boolean): void {\n this._isActive = active;\n }\n\n /** @internal */\n protected drawActive(ctx: CanvasRenderingContext2D) {\n ctx.shadowBlur = 30;\n ctx.shadowColor = \"gold\";\n return false;\n }\n\n /** @internal */\n public override drawDecoration(ctx: CanvasRenderingContext2D): void {\n if (!this.isActive || !this.drawActive(ctx))\n super.drawDecoration(ctx);\n }\n\n /** @internal */\n public override onMouseEnter(ev: BeButtonEvent) {\n // Lazily load the tooltip.\n if (undefined === this.title) {\n IModelReadRpcInterface.getClientForRouting(this.state.iModel.routingContext.token).getToolTipMessage(this.state.iModel.getRpcProps(), this.state.id).then((tooltipMsg) => {\n this.title = IModelApp.formatElementToolTip(tooltipMsg);\n }).catch((_) => {\n this.title = this.description;\n });\n }\n\n super.onMouseEnter(ev);\n this.onMouseEnterEvent.raiseEvent(this);\n }\n\n /** @internal */\n public override onMouseButton(ev: BeButtonEvent): boolean {\n if (InputSource.Mouse === ev.inputSource && BeButton.Data === ev.button && ev.isDown && ev.viewport)\n this.onMouseButtonEvent.raiseEvent(this);\n\n return true; // Don't allow clicks to be sent to active tool...\n }\n\n /** @internal */\n public override addMarker(context: DecorateContext) {\n super.addMarker(context);\n if (this.isHilited)\n ViewClipTool.drawClip(context, this.state.clip, undefined, { fillClipPlanes: true, hasPrimaryPlane: true });\n }\n}\n\n/** A Marker used to show a cluster of section locations.\n * @internal\n */\nexport class SectionMarkerCluster extends Marker {\n /** Create a new cluster marker */\n constructor(location: XYAndZ, size: XAndY, cluster: Cluster<SectionMarker>, image: MarkerImage | Promise<MarkerImage> | undefined) {\n super(location, size);\n\n this.imageOffset = new Point3d(0, 30);\n this.label = cluster.markers.length.toLocaleString();\n this.labelColor = \"black\";\n this.labelFont = \"bold 14px sans-serif\";\n\n const maxLen = 10;\n let title = \"\";\n cluster.markers.forEach((marker, index: number) => {\n if (index < maxLen) {\n if (title !== \"\")\n title += \"<br>\";\n title += marker.description;\n }\n });\n\n if (cluster.markers.length > maxLen)\n title += \"<br>...\";\n\n const div = document.createElement(\"div\");\n div.innerHTML = title;\n this.title = div;\n if (image)\n this.setImage(image);\n }\n\n /** Show the cluster as a white circle with an outline */\n public override drawFunc(ctx: CanvasRenderingContext2D): void {\n ctx.beginPath();\n ctx.strokeStyle = \"#372528\";\n ctx.fillStyle = \"white\";\n ctx.lineWidth = 5;\n ctx.arc(0, 0, 13, 0, Math.PI * 2);\n ctx.fill();\n ctx.stroke();\n }\n\n public override onMouseButton(_ev: BeButtonEvent): boolean { return true; } // Don't allow clicks to be sent to active tool...\n}\n\n/** A [MarkerSet]($frontend) containing [[SectionMarker]]s identifying [SectionDrawingLocation]($backend)s within a spatial view.\n * Typically used indirectly via [[HyperModelingDecorator]].\n * @public\n */\nexport class SectionMarkerSet extends MarkerSet<SectionMarker> {\n public override minimumClusterSize = 5;\n\n /** Constructor\n * @param viewport The viewport in which the markers are to be displayed.\n * @param markers The markers to be displayed.\n * @note Each marker's [[SectionDrawingLocationState]] must be associated with the same [IModelConnection]($frontend) as the viewport; any markers from other iModels will be omitted.\n */\n public constructor(viewport: ScreenViewport, markers: SectionMarker[]) {\n super(viewport);\n for (const marker of markers) {\n if (marker.state.iModel === viewport.iModel)\n this.markers.add(marker);\n }\n }\n\n /** The viewport in which the markers are to be displayed. */\n public override get viewport(): ScreenViewport {\n assert(undefined !== super.viewport);\n return super.viewport;\n }\n\n /** @internal */\n protected getClusterMarker(cluster: Cluster<SectionMarker>): Marker {\n return new SectionMarkerCluster(cluster.getClusterLocation(), cluster.markers[0].size, cluster, cluster.markers[0].image);\n }\n\n /** Find the SectionMarker corresponding to the specified [SectionDrawingLocation]($backend) Id. */\n public findMarkerById(sectionDrawingLocationId: Id64String): SectionMarker | undefined {\n for (const marker of this.markers)\n if (marker.state.id === sectionDrawingLocationId)\n return marker;\n\n return undefined;\n }\n}\n"]}
|
|
1
|
+
{"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;IACvC,qEAAqE;IACrD,KAAK,CAA8B;IACnD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AAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC5H,CAAC;IAED,mGAAmG;IAC5F,cAAc,CAAC,wBAAoC;QACxD,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO;YAC/B,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,wBAAwB;gBAC9C,OAAO,MAAM,CAAC;QAElB,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAnCD,4CAmCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module HyperModeling\n */\n\nimport { assert, BeEvent, Id64String } from \"@itwin/core-bentley\";\nimport { Point2d, Point3d, XAndY, XYAndZ } from \"@itwin/core-geometry\";\nimport { IModelReadRpcInterface } from \"@itwin/core-common\";\nimport {\n BeButton, BeButtonEvent, Cluster, DecorateContext, IModelApp, InputSource, Marker, MarkerImage, MarkerSet, ScreenViewport, ViewClipTool,\n} from \"@itwin/core-frontend\";\nimport { SectionDrawingLocationState } from \"./SectionDrawingLocationState\";\nimport { HyperModeling } from \"./HyperModeling\";\n\nconst markerSize = Point2d.create(40, 40);\n\n/** A [Marker]($frontend) associated with a [[SectionDrawingLocationState]], displayed as a canvas decoration at the location of the section.\n * Clicking on the marker toggles display of the section graphics. Mousing over the marker produces a toolbar with additional interactions.\n * @see [[HyperModelingDecorator]] for a [Decorator]($frontend) capable of displaying section markers for each section drawing location.\n * @see [[SectionMarkerHandler]] to customize the marker interactions.\n * @public\n */\nexport class SectionMarker extends Marker {\n /** The section drawing location state associated with the marker. */\n public readonly state: SectionDrawingLocationState;\n /** A description displayed as part of the tooltip when this marker is clustered with other markers. */\n public readonly description: string;\n /** @internal */\n public readonly onMouseEnterEvent = new BeEvent<(marker: SectionMarker) => void>();\n /** @internal */\n public readonly onMouseButtonEvent = new BeEvent<(marker: SectionMarker) => void>();\n /** @internal */\n private _isActive = false;\n\n /** Constructor, typically invoked indirectly via [[HyperModelingDecorator]].\n * @param state The section drawing location state this marker will represent.\n * @param pos The world coordinates at which to display the marker.\n * @param description A brief description of this marker, used as part of the tooltip when this marker is part of a cluster.\n * @param icon The icon displayed by the marker.\n * @param tooltip Optional detailed tooltip displayed on mouse hover. If undefined, the `description` is used instead.\n */\n public constructor(state: SectionDrawingLocationState) {\n super(state.placement.origin.clone(), markerSize);\n this.state = state;\n\n const data = HyperModeling.getMarkerData(state.sectionType);\n this.description = data.label;\n if (data.image)\n this.setImage(data.image);\n\n this.setScaleFactor({ low: .2, high: 1.4 }); // make size 20% at back of frustum and 140% at front of frustum (if camera is on)\n }\n\n /** @internal */\n public get isHilited(): boolean { return this._isHilited; }\n\n /** Returns true if this is the \"active\" section marker. At most one marker is active at a given time.\n * @see [[HyperModelingDecorator.activeMarker]].\n * @see [[HyperModelingDecorator.setActiveMarker]].\n * @see [[SectionMarkerHandler.toggleMarker]].\n */\n public get isActive(): boolean {\n return this._isActive;\n }\n\n /** @internal */\n public setActive(active: boolean): void {\n this._isActive = active;\n }\n\n /** @internal */\n protected drawActive(ctx: CanvasRenderingContext2D) {\n ctx.shadowBlur = 30;\n ctx.shadowColor = \"gold\";\n return false;\n }\n\n /** @internal */\n public override drawDecoration(ctx: CanvasRenderingContext2D): void {\n if (!this.isActive || !this.drawActive(ctx))\n super.drawDecoration(ctx);\n }\n\n /** @internal */\n public override onMouseEnter(ev: BeButtonEvent) {\n // Lazily load the tooltip.\n if (undefined === this.title) {\n IModelReadRpcInterface.getClientForRouting(this.state.iModel.routingContext.token).getToolTipMessage(this.state.iModel.getRpcProps(), this.state.id).then((tooltipMsg) => {\n this.title = IModelApp.formatElementToolTip(tooltipMsg);\n }).catch((_) => {\n this.title = this.description;\n });\n }\n\n super.onMouseEnter(ev);\n this.onMouseEnterEvent.raiseEvent(this);\n }\n\n /** @internal */\n public override onMouseButton(ev: BeButtonEvent): boolean {\n if (InputSource.Mouse === ev.inputSource && BeButton.Data === ev.button && ev.isDown && ev.viewport)\n this.onMouseButtonEvent.raiseEvent(this);\n\n return true; // Don't allow clicks to be sent to active tool...\n }\n\n /** @internal */\n public override addMarker(context: DecorateContext) {\n super.addMarker(context);\n if (this.isHilited)\n ViewClipTool.drawClip(context, this.state.clip, undefined, { fillClipPlanes: true, hasPrimaryPlane: true });\n }\n}\n\n/** A Marker used to show a cluster of section locations.\n * @internal\n */\nexport class SectionMarkerCluster extends Marker {\n /** Create a new cluster marker */\n constructor(location: XYAndZ, size: XAndY, cluster: Cluster<SectionMarker>, image: MarkerImage | Promise<MarkerImage> | undefined) {\n super(location, size);\n\n this.imageOffset = new Point3d(0, 30);\n this.label = cluster.markers.length.toLocaleString();\n this.labelColor = \"black\";\n this.labelFont = \"bold 14px sans-serif\";\n\n const maxLen = 10;\n let title = \"\";\n cluster.markers.forEach((marker, index: number) => {\n if (index < maxLen) {\n if (title !== \"\")\n title += \"<br>\";\n title += marker.description;\n }\n });\n\n if (cluster.markers.length > maxLen)\n title += \"<br>...\";\n\n const div = document.createElement(\"div\");\n div.innerHTML = title;\n this.title = div;\n if (image)\n this.setImage(image);\n }\n\n /** Show the cluster as a white circle with an outline */\n public override drawFunc(ctx: CanvasRenderingContext2D): void {\n ctx.beginPath();\n ctx.strokeStyle = \"#372528\";\n ctx.fillStyle = \"white\";\n ctx.lineWidth = 5;\n ctx.arc(0, 0, 13, 0, Math.PI * 2);\n ctx.fill();\n ctx.stroke();\n }\n\n public override onMouseButton(_ev: BeButtonEvent): boolean { return true; } // Don't allow clicks to be sent to active tool...\n}\n\n/** A [MarkerSet]($frontend) containing [[SectionMarker]]s identifying [SectionDrawingLocation]($backend)s within a spatial view.\n * Typically used indirectly via [[HyperModelingDecorator]].\n * @public\n */\nexport class SectionMarkerSet extends MarkerSet<SectionMarker> {\n public override minimumClusterSize = 5;\n\n /** Constructor\n * @param viewport The viewport in which the markers are to be displayed.\n * @param markers The markers to be displayed.\n * @note Each marker's [[SectionDrawingLocationState]] must be associated with the same [IModelConnection]($frontend) as the viewport; any markers from other iModels will be omitted.\n */\n public constructor(viewport: ScreenViewport, markers: SectionMarker[]) {\n super(viewport);\n for (const marker of markers) {\n if (marker.state.iModel === viewport.iModel)\n this.markers.add(marker);\n }\n }\n\n /** The viewport in which the markers are to be displayed. */\n public override get viewport(): ScreenViewport {\n assert(undefined !== super.viewport);\n return super.viewport;\n }\n\n /** @internal */\n protected getClusterMarker(cluster: Cluster<SectionMarker>): Marker {\n return new SectionMarkerCluster(cluster.getClusterLocation(), cluster.markers[0].size, cluster, cluster.markers[0].image);\n }\n\n /** Find the SectionMarker corresponding to the specified [SectionDrawingLocation]($backend) Id. */\n public findMarkerById(sectionDrawingLocationId: Id64String): SectionMarker | undefined {\n for (const marker of this.markers)\n if (marker.state.id === sectionDrawingLocationId)\n return marker;\n\n return undefined;\n }\n}\n"]}
|
package/lib/cjs/Tools.js
CHANGED
|
@@ -24,7 +24,7 @@ function parseToggle(arg) {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
class HyperModelingTool extends core_frontend_1.Tool {
|
|
27
|
-
static
|
|
27
|
+
static toolId = "HyperModeling";
|
|
28
28
|
static get minArgs() { return 0; }
|
|
29
29
|
static get maxArgs() { return 1; }
|
|
30
30
|
async run(enable, vp) {
|
|
@@ -46,7 +46,7 @@ class HyperModelingTool extends core_frontend_1.Tool {
|
|
|
46
46
|
* - boundaries: Whether to display clip volumes as boundary shapes for debugging purposes. Default: 0.
|
|
47
47
|
*/
|
|
48
48
|
class SectionGraphicsConfigTool extends core_frontend_1.Tool {
|
|
49
|
-
static
|
|
49
|
+
static toolId = "HyperModeling.Graphics.Config";
|
|
50
50
|
static get minArgs() { return 0; }
|
|
51
51
|
static get maxArgs() { return 4; }
|
|
52
52
|
async run(config) {
|
|
@@ -145,13 +145,13 @@ class SectionMarkerConfigTool extends core_frontend_1.Tool {
|
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
class SectionMarkerDefaultConfigTool extends SectionMarkerConfigTool {
|
|
148
|
-
static
|
|
148
|
+
static toolId = "HyperModeling.Marker.Default.Config";
|
|
149
149
|
update(config) {
|
|
150
150
|
HyperModeling_1.HyperModeling.updateConfiguration({ markers: config });
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
class SectionMarkerDecoratorConfigTool extends SectionMarkerConfigTool {
|
|
154
|
-
static
|
|
154
|
+
static toolId = "HyperModeling.Marker.Config";
|
|
155
155
|
update(config) {
|
|
156
156
|
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
157
157
|
const decorator = vp ? HyperModelingDecorator_1.HyperModelingDecorator.getForViewport(vp) : undefined;
|
package/lib/cjs/Tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tools.js","sourceRoot":"","sources":["../../src/Tools.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AA0LH,sCAMC;AA9LD,oDAAiD;AACjD,wDAAuE;AACvE,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,CAAC;QAC1B,KAAK,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC;QACvB,KAAK,KAAK,CAAC,CAAC,OAAO,KAAK,CAAC;QACzB,KAAK,QAAQ,CAAC,CAAC,OAAO,SAAS,CAAC;QAChC,OAAO,CAAC,CAAC,OAAO,GAAG,CAAC;IACtB,CAAC;AACH,CAAC;AAED,MAAM,iBAAkB,SAAQ,oBAAI;aACX,WAAM,GAAG,eAAe,CAAC;IACzC,MAAM,KAAc,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3C,MAAM,KAAc,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IAElC,KAAK,CAAC,GAAG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BAAiB,CAAC,CAAC;IAC5B,QAAQ,CAAC,yBAAyB,CAAC,CAAC;IACpC,QAAQ,CAAC,gCAAgC,CAAC,CAAC;IAC3C,QAAQ,CAAC,8BAA8B,CAAC,CAAC;AAC3C,CAAC","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 { IModelApp, ScreenViewport, Tool } 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: string): void {\r\n const register = (tool: typeof Tool) => IModelApp.tools.register(tool, namespace);\r\n register(HyperModelingTool);\r\n register(SectionGraphicsConfigTool);\r\n register(SectionMarkerDecoratorConfigTool);\r\n register(SectionMarkerDefaultConfigTool);\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Tools.js","sourceRoot":"","sources":["../../src/Tools.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AA0LH,sCAMC;AA9LD,oDAAiD;AACjD,wDAAuE;AACvE,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,CAAC;QAC1B,KAAK,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC;QACvB,KAAK,KAAK,CAAC,CAAC,OAAO,KAAK,CAAC;QACzB,KAAK,QAAQ,CAAC,CAAC,OAAO,SAAS,CAAC;QAChC,OAAO,CAAC,CAAC,OAAO,GAAG,CAAC;IACtB,CAAC;AACH,CAAC;AAED,MAAM,iBAAkB,SAAQ,oBAAI;IAC3B,MAAM,CAAU,MAAM,GAAG,eAAe,CAAC;IACzC,MAAM,KAAc,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3C,MAAM,KAAc,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IAElC,KAAK,CAAC,GAAG,CAAC,MAAgB,EAAE,EAAmB;QAC7D,EAAE,GAAG,EAAE,IAAI,yBAAS,CAAC,WAAW,CAAC,YAAY,CAAC;QAC9C,IAAI,EAAE;YACJ,MAAM,6BAAa,CAAC,WAAW,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QAE9C,OAAO,IAAI,CAAC;IACd,CAAC;IAEe,KAAK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yright (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 { IModelApp, ScreenViewport, Tool } 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: string): void {\r\n const register = (tool: typeof Tool) => IModelApp.tools.register(tool, namespace);\r\n register(HyperModelingTool);\r\n register(SectionGraphicsConfigTool);\r\n register(SectionMarkerDecoratorConfigTool);\r\n register(SectionMarkerDefaultConfigTool);\r\n}\r\n"]}
|
package/lib/esm/HyperModeling.js
CHANGED
|
@@ -22,8 +22,11 @@ function assertInitialized(maybe) {
|
|
|
22
22
|
* @public
|
|
23
23
|
*/
|
|
24
24
|
export class HyperModeling {
|
|
25
|
-
|
|
26
|
-
static
|
|
25
|
+
/** @internal */
|
|
26
|
+
static resources;
|
|
27
|
+
static _markerHandler;
|
|
28
|
+
static _markerConfig = {};
|
|
29
|
+
static _graphicsConfig = {};
|
|
27
30
|
static shutdown() {
|
|
28
31
|
this.resources = undefined;
|
|
29
32
|
this._markerHandler = undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HyperModeling.js","sourceRoot":"","sources":["../../src/HyperModeling.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAoC,sBAAsB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtH,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AA0B9D,SAAS,iBAAiB,CAAC,KAAuB;IAChD,IAAI,SAAS,KAAK,KAAK,CAAC,SAAS;QAC/B,MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;AACrG,CAAC;AAED;;;;;GAKG;AACH,MAAM,OAAO,aAAa;aAIT,kBAAa,GAAwB,EAAE,CAAC;aACxC,oBAAe,GAA0B,EAAE,CAAC;IAEnD,MAAM,CAAC,QAAQ;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;QAChC,IAAI,CAAC,aAA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I,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC;YACvC;gBACE,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC;QAC1C,CAAC;IACH,CAAC","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 } from \"@itwin/core-bentley\";\r\nimport { SectionType } from \"@itwin/core-common\";\r\nimport { IModelApp, IModelConnection, ScreenViewport, tryImageElementFromUrl, ViewManip } from \"@itwin/core-frontend\";\r\nimport { registerTools } from \"./Tools\";\r\nimport { HyperModelingDecorator } from \"./HyperModelingDecorator\";\r\nimport { HyperModelingConfig, SectionGraphicsConfig, SectionMarkerConfig } from \"./HyperModelingConfig\";\r\nimport { SectionMarkerHandler } from \"./SectionMarkerHandler\";\r\n\r\n/** @internal */\r\nexport interface MarkerData {\r\n readonly label: string;\r\n readonly image: HTMLImageElement | undefined;\r\n}\r\n\r\ninterface Resources {\r\n readonly namespace?: string;\r\n readonly markers: {\r\n readonly section: MarkerData;\r\n readonly plan: MarkerData;\r\n readonly elevation: MarkerData;\r\n readonly detail: MarkerData;\r\n };\r\n}\r\n\r\ninterface MaybeInitialized {\r\n resources?: Resources;\r\n}\r\n\r\ninterface Initialized {\r\n resources: Resources;\r\n}\r\n\r\nfunction assertInitialized(maybe: MaybeInitialized): asserts maybe is Initialized {\r\n if (undefined === maybe.resources)\r\n throw new Error(\"You must call HyperModeling.initialize before using the hypermodeling package\");\r\n}\r\n\r\n/** The API entry point for the hypermodeling package. Applications must call [[initialize]] and await the result before using the package.\r\n * The behavior of the package can be customized via a [[HyperModelingConfig]] supplied to [[initialize]], [[updateConfiguration]], or [[replaceConfiguration]].\r\n * Hypermodeling mode can be enabled or disabled via [[startOrStop]], which returns a [[HyperModelingDecorator]] when enabling hypermodeling.\r\n * Consult the package's `README.md` for a description of the available functionality.\r\n * @public\r\n */\r\nexport class HyperModeling {\r\n /** @internal */\r\n public static resources?: Resources;\r\n private static _markerHandler?: SectionMarkerHandler;\r\n private static _markerConfig: SectionMarkerConfig = {};\r\n private static _graphicsConfig: SectionGraphicsConfig = {};\r\n\r\n private static shutdown() {\r\n this.resources = undefined;\r\n this._markerHandler = undefined;\r\n this._markerConfig = {};\r\n this._graphicsConfig = {};\r\n }\r\n\r\n /** Returns whether the hypermodeling package is initialized.\r\n * @see [[HyperModeling.initialize]] to initialize the package.\r\n */\r\n public static get isInitialized(): boolean {\r\n return undefined !== this.resources;\r\n }\r\n\r\n /** Invoke this method to initialize the hypermodeling package for use. You *must* await the result before using any of this package's APIs.\r\n * Typically an application would invoke this after [IModelApp.startup]($frontend), e.g.,\r\n * ```ts\r\n * await IModelApp.startup();\r\n * await HyperModeling.initialize();\r\n * ```\r\n * Calling this method again after the first initialization behaves the same as calling [[HyperModeling.replaceConfiguration]].\r\n * @note The hypermodeling package will be reset to uninitialized after [IModelApp.shutdown]($frontend) is invoked.\r\n * @see [[replaceConfiguration]] and [[updateConfiguration]] to modify the configuration after initialization.\r\n */\r\n public static async initialize(config?: HyperModelingConfig): Promise<void> {\r\n if (undefined !== this.resources) {\r\n this.replaceConfiguration(config);\r\n return;\r\n }\r\n\r\n // clean up if we're being shut down\r\n IModelApp.onBeforeShutdown.addListener(() => this.shutdown());\r\n\r\n const namespace = \"HyperModeling\";\r\n await IModelApp.localization.registerNamespace(namespace);\r\n\r\n const loadImages = [\r\n tryImageElementFromUrl(`${IModelApp.publicPath}section-marker.svg`),\r\n tryImageElementFromUrl(`${IModelApp.publicPath}detail-marker.svg`),\r\n tryImageElementFromUrl(`${IModelApp.publicPath}elevation-marker.svg`),\r\n tryImageElementFromUrl(`${IModelApp.publicPath}plan-marker.svg`),\r\n ];\r\n\r\n const images = await Promise.all(loadImages);\r\n this.resources = {\r\n namespace,\r\n markers: {\r\n section: { image: images[0], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.SectionCallout\") },\r\n detail: { image: images[1], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.DetailCallout\") },\r\n elevation: { image: images[2], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.ElevationCallout\") },\r\n plan: { image: images[3], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.PlanCallout\") },\r\n },\r\n };\r\n\r\n registerTools(namespace);\r\n this.replaceConfiguration(config);\r\n }\r\n\r\n private static async ensureInitialized(): Promise<void> {\r\n if (undefined === this.resources)\r\n await this.initialize();\r\n\r\n assertInitialized(this);\r\n }\r\n\r\n /** Replaces the current package configuration, overwriting all previous settings. Passing `undefined` resets all settings to defaults.\r\n * @see [[HyperModeling.updateConfiguration]] for overriding specific aspects of the configuration.\r\n */\r\n public static replaceConfiguration(config?: HyperModelingConfig): void {\r\n config = config ?? {};\r\n this._markerHandler = config.markerHandler ?? new SectionMarkerHandler();\r\n this._markerConfig = config.markers ? { ...config.markers } : {};\r\n this._graphicsConfig = config.graphics ? { ...config.graphics } : {};\r\n }\r\n\r\n /** Overrides specific aspects of the current package configuration. Any field that is not `undefined` will be replaced in the current configuration;\r\n * the rest will retain their current values.\r\n * @see [[HyperModeling.replaceConfiguration]].\r\n */\r\n public static updateConfiguration(config: HyperModelingConfig): void {\r\n this._markerHandler = config.markerHandler ?? this._markerHandler;\r\n\r\n if (config.markers) {\r\n this._markerConfig = {\r\n ignoreModelSelector: config.markers.ignoreModelSelector ?? this._markerConfig.ignoreModelSelector,\r\n ignoreCategorySelector: config.markers.ignoreCategorySelector ?? this._markerConfig.ignoreCategorySelector,\r\n hiddenSectionTypes: config.markers.hiddenSectionTypes ?? this._markerConfig.hiddenSectionTypes,\r\n };\r\n }\r\n\r\n if (config.graphics) {\r\n this._graphicsConfig = {\r\n ignoreClip: config.graphics.ignoreClip ?? this._graphicsConfig.ignoreClip,\r\n debugClipVolumes: config.graphics.debugClipVolumes ?? this._graphicsConfig.debugClipVolumes,\r\n hideSectionGraphics: config.graphics.hideSectionGraphics ?? this._graphicsConfig.hideSectionGraphics,\r\n hideSheetAnnotations: config.graphics.hideSheetAnnotations ?? this._graphicsConfig.hideSheetAnnotations,\r\n };\r\n\r\n IModelApp.viewManager.invalidateViewportScenes();\r\n }\r\n }\r\n\r\n /** The handler that defines interactions with [[SectionMarker]]s.\r\n * @see [[initialize]] to override the default handler at package initialization.\r\n * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current handler.\r\n */\r\n public static get markerHandler(): SectionMarkerHandler {\r\n assertInitialized(this);\r\n assert(undefined !== this._markerHandler);\r\n return this._markerHandler;\r\n }\r\n\r\n /** The current marker display configuration applied to any newly-created [[HyperModelingDecorator]]s.\r\n * @see [[initialize]] to override the default configuration at package initialization.\r\n * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current configuration.\r\n * @see [[HyperModelingDecorator.replaceConfiguration]] or [[HyperModelingDecorator.updateConfiguration]] to change the configuration for an existing decorator.\r\n */\r\n public static get markerConfig(): SectionMarkerConfig {\r\n return this._markerConfig;\r\n }\r\n\r\n /** This graphics options applied to graphics displayed by all [[HyperModelingDecorator]]s.\r\n * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current configuration.\r\n */\r\n public static get graphicsConfig(): SectionGraphicsConfig {\r\n return this._graphicsConfig;\r\n }\r\n\r\n /** Returns true if the specified iModel contains any [SectionDrawingLocation]($backend)s. Hypermodeling is based on section drawing locations,\r\n * so if none are present, hypermodeling features are not relevant to the iModel. Attempting to use those features with such an iModel is fine,\r\n * but probably not useful.\r\n */\r\n public static async isSupportedForIModel(imodel: IModelConnection): Promise<boolean> {\r\n try {\r\n const reader = imodel.createQueryReader(\"SELECT ECInstanceId FROM bis.SectionDrawingLocation LIMIT 1\");\r\n return await reader.step(); // i.e., are any results are returned?\r\n } catch {\r\n // An iModel with a version of BisCore older than 1.0.11 will produce an expected \"table not found\" on the SectionDrawingLocation ECClass.\r\n return false;\r\n }\r\n }\r\n\r\n /** Returns whether hypermodeling is currently enabled for the specified viewport.\r\n * @see [[startOrStop]] to enable or disable hypermodeling for a viewport.\r\n */\r\n public static isEnabledForViewport(viewport: ScreenViewport): boolean {\r\n return undefined !== HyperModelingDecorator.getForViewport(viewport);\r\n }\r\n\r\n /** Start or stop hypermodeling mode for the specified viewport.\r\n * Enabling hypermodeling registers and returns a [[HyperModelingDecorator]] to display [[SectionMarker]]s within the viewport.\r\n * Disabling hypermodeling removes that decorator.\r\n * @param viewport The hypermodeling viewport\r\n * @param start `true` to enter hypermodeling mode, `false` to exit, or `undefined` to toggle the current mode.\r\n * @returns The new decorator is hypermodeling was successfully enabled.\r\n * @note Enabling hypermodeling may fail if the viewport is not viewing a spatial model or if the viewport's iModel does not support hypermodeling.\r\n * @see [[start]] and [[stop]].\r\n * @see [[isSupportedForIModel]].\r\n */\r\n public static async startOrStop(viewport: ScreenViewport, start?: boolean): Promise<HyperModelingDecorator | undefined> {\r\n // Help out the caller since we're async anyway...\r\n await this.ensureInitialized();\r\n\r\n const decorator = HyperModelingDecorator.getForViewport(viewport);\r\n if (undefined === start)\r\n start = undefined === decorator;\r\n\r\n if (start) {\r\n return this._start(viewport);\r\n } else {\r\n decorator?.[Symbol.dispose]();\r\n return undefined;\r\n }\r\n }\r\n\r\n /** Start hypermodeling mode for the specified viewport if it is not currently enabled.\r\n * If hypermodeling is already enabled for the viewport, the existing decorator is returned; otherwise, a new decorator is created.\r\n * @param viewport The viewport for which to enable hypermodeling\r\n * @returns The decorator that implements hypermodeling features for the viewport, or `undefined` if hypermodeling could not be enabled.\r\n * @note Enabling hypermodeling may fail if the viewport is not viewing a spatial model or if the viewport's iModel does not support hypermodeling.\r\n */\r\n public static async start(viewport: ScreenViewport): Promise<HyperModelingDecorator | undefined> {\r\n await this.ensureInitialized();\r\n return this._start(viewport);\r\n }\r\n\r\n private static async _start(viewport: ScreenViewport): Promise<HyperModelingDecorator | undefined> {\r\n assertInitialized(this);\r\n if (!viewport.view.isSpatialView())\r\n return undefined;\r\n\r\n let decorator = HyperModelingDecorator.getForViewport(viewport);\r\n if (!decorator)\r\n decorator = await HyperModelingDecorator.create(viewport, this._markerConfig);\r\n\r\n if (undefined !== decorator && viewport.view.isCameraOn) {\r\n // We want the 2d graphics to align with the 3d geometry. Perspective ruins that.\r\n viewport.view.turnCameraOff();\r\n ViewManip.fitView(viewport, false, { noSaveInUndo: true });\r\n viewport.clearViewUndo();\r\n }\r\n\r\n return decorator;\r\n }\r\n\r\n /** Stop hypermodeling mode for the specified viewport if it is currently enabled. This disposes of the [[HyperModelingDecorator]] associated with the viewport.\r\n * @see [[start]] to enable hypermodeling for a viewport.\r\n * @see [[startOrStop]] to toggle hypermodeling mode.\r\n */\r\n public static stop(viewport: ScreenViewport): void {\r\n const decorator = HyperModelingDecorator.getForViewport(viewport);\r\n decorator?.[Symbol.dispose]();\r\n }\r\n\r\n /** @internal */\r\n public static get namespace(): string | undefined {\r\n assertInitialized(this);\r\n return this.resources.namespace;\r\n }\r\n\r\n /** @internal */\r\n public static getMarkerData(type: SectionType): MarkerData {\r\n assertInitialized(this);\r\n switch (type) {\r\n case SectionType.Plan:\r\n return this.resources.markers.plan;\r\n case SectionType.Elevation:\r\n return this.resources.markers.elevation;\r\n case SectionType.Detail:\r\n return this.resources.markers.detail;\r\n default:\r\n return this.resources.markers.section;\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"HyperModeling.js","sourceRoot":"","sources":["../../src/HyperModeling.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAoC,sBAAsB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtH,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,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Q,CAAC,CAAC;QAClE,SAAS,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAChC,CAAC;IAED,gBAAgB;IACT,MAAM,KAAK,SAAS;QACzB,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;IAClC,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,aAAa,CAAC,IAAiB;QAC3C,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACxB,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,WAAW,CAAC,IAAI;gBACnB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;YACrC,KAAK,WAAW,CAAC,SAAS;gBACxB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC;YAC1C,KAAK,WAAW,CAAC,MAAM;gBACrB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC;YACvC;gBACE,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC;QAC1C,CAAC;IACH,CAAC","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 } from \"@itwin/core-bentley\";\r\nimport { SectionType } from \"@itwin/core-common\";\r\nimport { IModelApp, IModelConnection, ScreenViewport, tryImageElementFromUrl, ViewManip } from \"@itwin/core-frontend\";\r\nimport { registerTools } from \"./Tools\";\r\nimport { HyperModelingDecorator } from \"./HyperModelingDecorator\";\r\nimport { HyperModelingConfig, SectionGraphicsConfig, SectionMarkerConfig } from \"./HyperModelingConfig\";\r\nimport { SectionMarkerHandler } from \"./SectionMarkerHandler\";\r\n\r\n/** @internal */\r\nexport interface MarkerData {\r\n readonly label: string;\r\n readonly image: HTMLImageElement | undefined;\r\n}\r\n\r\ninterface Resources {\r\n readonly namespace?: string;\r\n readonly markers: {\r\n readonly section: MarkerData;\r\n readonly plan: MarkerData;\r\n readonly elevation: MarkerData;\r\n readonly detail: MarkerData;\r\n };\r\n}\r\n\r\ninterface MaybeInitialized {\r\n resources?: Resources;\r\n}\r\n\r\ninterface Initialized {\r\n resources: Resources;\r\n}\r\n\r\nfunction assertInitialized(maybe: MaybeInitialized): asserts maybe is Initialized {\r\n if (undefined === maybe.resources)\r\n throw new Error(\"You must call HyperModeling.initialize before using the hypermodeling package\");\r\n}\r\n\r\n/** The API entry point for the hypermodeling package. Applications must call [[initialize]] and await the result before using the package.\r\n * The behavior of the package can be customized via a [[HyperModelingConfig]] supplied to [[initialize]], [[updateConfiguration]], or [[replaceConfiguration]].\r\n * Hypermodeling mode can be enabled or disabled via [[startOrStop]], which returns a [[HyperModelingDecorator]] when enabling hypermodeling.\r\n * Consult the package's `README.md` for a description of the available functionality.\r\n * @public\r\n */\r\nexport class HyperModeling {\r\n /** @internal */\r\n public static resources?: Resources;\r\n private static _markerHandler?: SectionMarkerHandler;\r\n private static _markerConfig: SectionMarkerConfig = {};\r\n private static _graphicsConfig: SectionGraphicsConfig = {};\r\n\r\n private static shutdown() {\r\n this.resources = undefined;\r\n this._markerHandler = undefined;\r\n this._markerConfig = {};\r\n this._graphicsConfig = {};\r\n }\r\n\r\n /** Returns whether the hypermodeling package is initialized.\r\n * @see [[HyperModeling.initialize]] to initialize the package.\r\n */\r\n public static get isInitialized(): boolean {\r\n return undefined !== this.resources;\r\n }\r\n\r\n /** Invoke this method to initialize the hypermodeling package for use. You *must* await the result before using any of this package's APIs.\r\n * Typically an application would invoke this after [IModelApp.startup]($frontend), e.g.,\r\n * ```ts\r\n * await IModelApp.startup();\r\n * await HyperModeling.initialize();\r\n * ```\r\n * Calling this method again after the first initialization behaves the same as calling [[HyperModeling.replaceConfiguration]].\r\n * @note The hypermodeling package will be reset to uninitialized after [IModelApp.shutdown]($frontend) is invoked.\r\n * @see [[replaceConfiguration]] and [[updateConfiguration]] to modify the configuration after initialization.\r\n */\r\n public static async initialize(config?: HyperModelingConfig): Promise<void> {\r\n if (undefined !== this.resources) {\r\n this.replaceConfiguration(config);\r\n return;\r\n }\r\n\r\n // clean up if we're being shut down\r\n IModelApp.onBeforeShutdown.addListener(() => this.shutdown());\r\n\r\n const namespace = \"HyperModeling\";\r\n await IModelApp.localization.registerNamespace(namespace);\r\n\r\n const loadImages = [\r\n tryImageElementFromUrl(`${IModelApp.publicPath}section-marker.svg`),\r\n tryImageElementFromUrl(`${IModelApp.publicPath}detail-marker.svg`),\r\n tryImageElementFromUrl(`${IModelApp.publicPath}elevation-marker.svg`),\r\n tryImageElementFromUrl(`${IModelApp.publicPath}plan-marker.svg`),\r\n ];\r\n\r\n const images = await Promise.all(loadImages);\r\n this.resources = {\r\n namespace,\r\n markers: {\r\n section: { image: images[0], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.SectionCallout\") },\r\n detail: { image: images[1], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.DetailCallout\") },\r\n elevation: { image: images[2], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.ElevationCallout\") },\r\n plan: { image: images[3], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.PlanCallout\") },\r\n },\r\n };\r\n\r\n registerTools(namespace);\r\n this.replaceConfiguration(config);\r\n }\r\n\r\n private static async ensureInitialized(): Promise<void> {\r\n if (undefined === this.resources)\r\n await this.initialize();\r\n\r\n assertInitialized(this);\r\n }\r\n\r\n /** Replaces the current package configuration, overwriting all previous settings. Passing `undefined` resets all settings to defaults.\r\n * @see [[HyperModeling.updateConfiguration]] for overriding specific aspects of the configuration.\r\n */\r\n public static replaceConfiguration(config?: HyperModelingConfig): void {\r\n config = config ?? {};\r\n this._markerHandler = config.markerHandler ?? new SectionMarkerHandler();\r\n this._markerConfig = config.markers ? { ...config.markers } : {};\r\n this._graphicsConfig = config.graphics ? { ...config.graphics } : {};\r\n }\r\n\r\n /** Overrides specific aspects of the current package configuration. Any field that is not `undefined` will be replaced in the current configuration;\r\n * the rest will retain their current values.\r\n * @see [[HyperModeling.replaceConfiguration]].\r\n */\r\n public static updateConfiguration(config: HyperModelingConfig): void {\r\n this._markerHandler = config.markerHandler ?? this._markerHandler;\r\n\r\n if (config.markers) {\r\n this._markerConfig = {\r\n ignoreModelSelector: config.markers.ignoreModelSelector ?? this._markerConfig.ignoreModelSelector,\r\n ignoreCategorySelector: config.markers.ignoreCategorySelector ?? this._markerConfig.ignoreCategorySelector,\r\n hiddenSectionTypes: config.markers.hiddenSectionTypes ?? this._markerConfig.hiddenSectionTypes,\r\n };\r\n }\r\n\r\n if (config.graphics) {\r\n this._graphicsConfig = {\r\n ignoreClip: config.graphics.ignoreClip ?? this._graphicsConfig.ignoreClip,\r\n debugClipVolumes: config.graphics.debugClipVolumes ?? this._graphicsConfig.debugClipVolumes,\r\n hideSectionGraphics: config.graphics.hideSectionGraphics ?? this._graphicsConfig.hideSectionGraphics,\r\n hideSheetAnnotations: config.graphics.hideSheetAnnotations ?? this._graphicsConfig.hideSheetAnnotations,\r\n };\r\n\r\n IModelApp.viewManager.invalidateViewportScenes();\r\n }\r\n }\r\n\r\n /** The handler that defines interactions with [[SectionMarker]]s.\r\n * @see [[initialize]] to override the default handler at package initialization.\r\n * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current handler.\r\n */\r\n public static get markerHandler(): SectionMarkerHandler {\r\n assertInitialized(this);\r\n assert(undefined !== this._markerHandler);\r\n return this._markerHandler;\r\n }\r\n\r\n /** The current marker display configuration applied to any newly-created [[HyperModelingDecorator]]s.\r\n * @see [[initialize]] to override the default configuration at package initialization.\r\n * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current configuration.\r\n * @see [[HyperModelingDecorator.replaceConfiguration]] or [[HyperModelingDecorator.updateConfiguration]] to change the configuration for an existing decorator.\r\n */\r\n public static get markerConfig(): SectionMarkerConfig {\r\n return this._markerConfig;\r\n }\r\n\r\n /** This graphics options applied to graphics displayed by all [[HyperModelingDecorator]]s.\r\n * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current configuration.\r\n */\r\n public static get graphicsConfig(): SectionGraphicsConfig {\r\n return this._graphicsConfig;\r\n }\r\n\r\n /** Returns true if the specified iModel contains any [SectionDrawingLocation]($backend)s. Hypermodeling is based on section drawing locations,\r\n * so if none are present, hypermodeling features are not relevant to the iModel. Attempting to use those features with such an iModel is fine,\r\n * but probably not useful.\r\n */\r\n public static async isSupportedForIModel(imodel: IModelConnection): Promise<boolean> {\r\n try {\r\n const reader = imodel.createQueryReader(\"SELECT ECInstanceId FROM bis.SectionDrawingLocation LIMIT 1\");\r\n return await reader.step(); // i.e., are any results are returned?\r\n } catch {\r\n // An iModel with a version of BisCore older than 1.0.11 will produce an expected \"table not found\" on the SectionDrawingLocation ECClass.\r\n return false;\r\n }\r\n }\r\n\r\n /** Returns whether hypermodeling is currently enabled for the specified viewport.\r\n * @see [[startOrStop]] to enable or disable hypermodeling for a viewport.\r\n */\r\n public static isEnabledForViewport(viewport: ScreenViewport): boolean {\r\n return undefined !== HyperModelingDecorator.getForViewport(viewport);\r\n }\r\n\r\n /** Start or stop hypermodeling mode for the specified viewport.\r\n * Enabling hypermodeling registers and returns a [[HyperModelingDecorator]] to display [[SectionMarker]]s within the viewport.\r\n * Disabling hypermodeling removes that decorator.\r\n * @param viewport The hypermodeling viewport\r\n * @param start `true` to enter hypermodeling mode, `false` to exit, or `undefined` to toggle the current mode.\r\n * @returns The new decorator is hypermodeling was successfully enabled.\r\n * @note Enabling hypermodeling may fail if the viewport is not viewing a spatial model or if the viewport's iModel does not support hypermodeling.\r\n * @see [[start]] and [[stop]].\r\n * @see [[isSupportedForIModel]].\r\n */\r\n public static async startOrStop(viewport: ScreenViewport, start?: boolean): Promise<HyperModelingDecorator | undefined> {\r\n // Help out the caller since we're async anyway...\r\n await this.ensureInitialized();\r\n\r\n const decorator = HyperModelingDecorator.getForViewport(viewport);\r\n if (undefined === start)\r\n start = undefined === decorator;\r\n\r\n if (start) {\r\n return this._start(viewport);\r\n } else {\r\n decorator?.[Symbol.dispose]();\r\n return undefined;\r\n }\r\n }\r\n\r\n /** Start hypermodeling mode for the specified viewport if it is not currently enabled.\r\n * If hypermodeling is already enabled for the viewport, the existing decorator is returned; otherwise, a new decorator is created.\r\n * @param viewport The viewport for which to enable hypermodeling\r\n * @returns The decorator that implements hypermodeling features for the viewport, or `undefined` if hypermodeling could not be enabled.\r\n * @note Enabling hypermodeling may fail if the viewport is not viewing a spatial model or if the viewport's iModel does not support hypermodeling.\r\n */\r\n public static async start(viewport: ScreenViewport): Promise<HyperModelingDecorator | undefined> {\r\n await this.ensureInitialized();\r\n return this._start(viewport);\r\n }\r\n\r\n private static async _start(viewport: ScreenViewport): Promise<HyperModelingDecorator | undefined> {\r\n assertInitialized(this);\r\n if (!viewport.view.isSpatialView())\r\n return undefined;\r\n\r\n let decorator = HyperModelingDecorator.getForViewport(viewport);\r\n if (!decorator)\r\n decorator = await HyperModelingDecorator.create(viewport, this._markerConfig);\r\n\r\n if (undefined !== decorator && viewport.view.isCameraOn) {\r\n // We want the 2d graphics to align with the 3d geometry. Perspective ruins that.\r\n viewport.view.turnCameraOff();\r\n ViewManip.fitView(viewport, false, { noSaveInUndo: true });\r\n viewport.clearViewUndo();\r\n }\r\n\r\n return decorator;\r\n }\r\n\r\n /** Stop hypermodeling mode for the specified viewport if it is currently enabled. This disposes of the [[HyperModelingDecorator]] associated with the viewport.\r\n * @see [[start]] to enable hypermodeling for a viewport.\r\n * @see [[startOrStop]] to toggle hypermodeling mode.\r\n */\r\n public static stop(viewport: ScreenViewport): void {\r\n const decorator = HyperModelingDecorator.getForViewport(viewport);\r\n decorator?.[Symbol.dispose]();\r\n }\r\n\r\n /** @internal */\r\n public static get namespace(): string | undefined {\r\n assertInitialized(this);\r\n return this.resources.namespace;\r\n }\r\n\r\n /** @internal */\r\n public static getMarkerData(type: SectionType): MarkerData {\r\n assertInitialized(this);\r\n switch (type) {\r\n case SectionType.Plan:\r\n return this.resources.markers.plan;\r\n case SectionType.Elevation:\r\n return this.resources.markers.elevation;\r\n case SectionType.Detail:\r\n return this.resources.markers.detail;\r\n default:\r\n return this.resources.markers.section;\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -22,6 +22,10 @@ async function createMarkers(vp) {
|
|
|
22
22
|
return new SectionMarkerSet(vp, markers);
|
|
23
23
|
}
|
|
24
24
|
class MarkerToolbarProvider {
|
|
25
|
+
_viewport;
|
|
26
|
+
marker;
|
|
27
|
+
toolbarProps;
|
|
28
|
+
onToolbarItemExecuted;
|
|
25
29
|
constructor(marker, decorator) {
|
|
26
30
|
this.marker = marker;
|
|
27
31
|
this._viewport = decorator.viewport;
|
|
@@ -46,6 +50,18 @@ class MarkerToolbarProvider {
|
|
|
46
50
|
* @public
|
|
47
51
|
*/
|
|
48
52
|
export class HyperModelingDecorator {
|
|
53
|
+
/** The set of [[SectionMarker]]s controlled by this decorator. */
|
|
54
|
+
markers;
|
|
55
|
+
_config;
|
|
56
|
+
_removeEventListeners = new Array();
|
|
57
|
+
_iModel;
|
|
58
|
+
_needSync = false;
|
|
59
|
+
_toolbarProvider;
|
|
60
|
+
_tiledGraphicsProvider;
|
|
61
|
+
_activeMarker;
|
|
62
|
+
_appliedSpatialView;
|
|
63
|
+
/** @internal */
|
|
64
|
+
syncImmediately = false;
|
|
49
65
|
/** Create a new decorator and register it with the [ViewManager]($frontend). Typically invoked indirectly via [[HyperModeling.startOrStop]]. */
|
|
50
66
|
static async create(vp, config) {
|
|
51
67
|
const markers = await createMarkers(vp);
|
|
@@ -120,17 +136,13 @@ export class HyperModelingDecorator {
|
|
|
120
136
|
return true;
|
|
121
137
|
}
|
|
122
138
|
/** @internal */
|
|
139
|
+
useCachedDecorations = true;
|
|
140
|
+
/** @internal */
|
|
123
141
|
decorate(context) {
|
|
124
142
|
if (this.viewport.view.is3d())
|
|
125
143
|
this.markers.addDecoration(context);
|
|
126
144
|
}
|
|
127
145
|
constructor(markers, config) {
|
|
128
|
-
this._removeEventListeners = new Array();
|
|
129
|
-
this._needSync = false;
|
|
130
|
-
/** @internal */
|
|
131
|
-
this.syncImmediately = false;
|
|
132
|
-
/** @internal */
|
|
133
|
-
this.useCachedDecorations = true;
|
|
134
146
|
this.markers = markers;
|
|
135
147
|
this._config = { ...config };
|
|
136
148
|
this._iModel = this.viewport.iModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HyperModelingDecorator.js","sourceRoot":"","sources":["../../src/HyperModelingDecorator.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAS,MAAM,sBAAsB,CAAC;AAExD,OAAO,EACoC,SAAS,EAA6E,YAAY,GAC5I,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAwB,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,KAAK,UAAU,aAAa,CAAC,EAAkB;IAC7C,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE;QAC1B,OAAO,SAAS,CAAC;IAEnB,MAAM,MAAM,GAAG,MAAM,2BAA2B,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;IACrE,IAAI,CAAC,KAAK,MAAM,CAAC,MAAM;QACrB,OAAO,SAAS,CAAC;IAEnB,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;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------------------------------------\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 { Transform, XAndY } from \"@itwin/core-geometry\";\nimport type { AbstractToolbarProps } from \"@itwin/appui-abstract\";\nimport {\n ChangeFlags, DecorateContext, Decorator, IModelApp, IModelConnection, ScreenViewport, SpatialViewState, TiledGraphicsProvider, ViewClipTool,\n} from \"@itwin/core-frontend\";\nimport { SectionMarker, SectionMarkerSet } from \"./SectionMarkers\";\nimport { SectionDrawingLocationState } from \"./SectionDrawingLocationState\";\nimport { createSectionGraphicsProvider } from \"./SectionGraphicsProvider\";\nimport { PopupToolbarManager, PopupToolbarProvider } from \"./PopupToolbar\";\nimport { HyperModeling } from \"./HyperModeling\";\nimport { SectionMarkerConfig } from \"./HyperModelingConfig\";\n\nasync function createMarkers(vp: ScreenViewport): Promise<SectionMarkerSet | undefined> {\n if (!vp.view.isSpatialView())\n return undefined;\n\n const states = await SectionDrawingLocationState.queryAll(vp.iModel);\n if (0 === states.length)\n return undefined;\n\n const markers = states.map((state) => new SectionMarker(state));\n return new SectionMarkerSet(vp, markers);\n}\n\nclass MarkerToolbarProvider implements PopupToolbarProvider {\n private readonly _viewport: ScreenViewport;\n public readonly marker: SectionMarker;\n public readonly toolbarProps: AbstractToolbarProps;\n public readonly onToolbarItemExecuted: (id: string) => void;\n\n public constructor(marker: SectionMarker, decorator: HyperModelingDecorator) {\n this.marker = marker;\n this._viewport = decorator.viewport;\n this.toolbarProps = HyperModeling.markerHandler.getToolbarProps(marker, decorator);\n this.onToolbarItemExecuted = (id) => HyperModeling.markerHandler.executeCommand(id, marker, decorator); // eslint-disable-line @typescript-eslint/promise-function-async\n }\n\n public get overToolbarHotspot() {\n return this.marker.isHilited;\n }\n\n public get toolbarLocation(): XAndY {\n return { x: this.marker.rect.right, y: this.marker.rect.top };\n }\n\n public get htmlElement() {\n return this._viewport.canvas;\n }\n}\n\n/** A [Decorator]($frontend) that displays a [[SectionMarker]] for each [SectionDrawingLocation]($backend) in the view.\n * Clicking on a marker toggles the section and the display of associated 2d graphics.\n * Hovering over a marker opens a mini toolbar with additional interactions.\n * @see [[SectionMarkerHandler]] to customize the marker interactions.\n * @see [[HyperModeling.startOrStop]] to enable or disable the decorator for a viewport.\n * @public\n */\nexport class HyperModelingDecorator implements Decorator {\n /** The set of [[SectionMarker]]s controlled by this decorator. */\n public readonly markers: SectionMarkerSet;\n private _config: SectionMarkerConfig;\n private readonly _removeEventListeners = new Array<() => void>();\n private readonly _iModel: IModelConnection;\n private _needSync = false;\n private _toolbarProvider?: MarkerToolbarProvider;\n private _tiledGraphicsProvider?: TiledGraphicsProvider;\n private _activeMarker?: SectionMarker;\n private _appliedSpatialView?: SpatialViewState;\n /** @internal */\n public syncImmediately = false;\n\n /** Create a new decorator and register it with the [ViewManager]($frontend). Typically invoked indirectly via [[HyperModeling.startOrStop]]. */\n public static async create(vp: ScreenViewport, config: SectionMarkerConfig): Promise<HyperModelingDecorator | undefined> {\n const markers = await createMarkers(vp);\n return undefined !== markers ? new HyperModelingDecorator(markers, config) : undefined;\n }\n\n /** Obtain the decorator associated with the specified viewport, if any. */\n public static getForViewport(vp: ScreenViewport): HyperModelingDecorator | undefined {\n for (const decorator of IModelApp.viewManager.decorators)\n if (decorator instanceof HyperModelingDecorator && decorator.viewport === vp)\n return decorator;\n\n return undefined;\n }\n\n /** The viewport into which this decorator draws its [[SectionMarker]]s. */\n public get viewport(): ScreenViewport {\n return this.markers.viewport;\n }\n\n /** The currently active marker. A marker typically becomes active when the user clicks on it.\n * @see [[setActiveMarker]] to change the active marker without user interaction.\n */\n public get activeMarker(): SectionMarker | undefined {\n return this._activeMarker;\n }\n\n /** @internal */\n public get config(): SectionMarkerConfig {\n return this._config;\n }\n\n /** Replaces the current marker display configuration, overwriting all previous settings. Passing `undefined` resets all settings to defaults.\n * @see [[updateConfiguration]] to override specific aspects of the configuration\n * @see [[HyperModeling.replaceConfiguration]] to replace the global configuration.\n */\n public replaceConfiguration(config?: SectionMarkerConfig): void {\n this._config = config ? { ...config } : {};\n this.requestSync();\n }\n\n /** Overrides specific aspects of the current marker display configuration.\n * Any field that is not `undefined` will be replaced in the current configuration; the rest will retain their current values.\n * @see [[replaceConfiguration]] to override all settings.\n * @see [[HyperModeling.updateConfiguration]] to update the global configuration.\n */\n public updateConfiguration(config: SectionMarkerConfig): void {\n this._config = {\n ignoreModelSelector: config.ignoreModelSelector ?? this._config.ignoreModelSelector,\n ignoreCategorySelector: config.ignoreCategorySelector ?? this._config.ignoreCategorySelector,\n hiddenSectionTypes: config.hiddenSectionTypes ?? this._config.hiddenSectionTypes,\n };\n\n this.requestSync();\n }\n\n /** Sets the currently active marker. This function is invoked when the user clicks on a marker, but may also be called manually to produce the same result.\n * Changing the active marker first deactivates the currently active marker, if any; then activates the specified marker, if supplied.\n * Returns false if marker activation fails.\n * @see [[activeMarker]] to obtain the currently active section marker.\n * @see [[SectionMarkerHandler.activateMarker]] to control what happens when a marker is activated.\n * @see [[SectionMarkerHandler.deactivateMarker]] to control what happens when a marker is deactivated.\n */\n public async setActiveMarker(marker: SectionMarker | undefined): Promise<boolean> {\n if (marker === this.activeMarker)\n return true;\n\n if (this.activeMarker) {\n this.activeMarker.setActive(false);\n await HyperModeling.markerHandler.deactivateMarker(this.activeMarker, this);\n this._activeMarker = undefined;\n }\n\n if (marker) {\n if (!await HyperModeling.markerHandler.activateMarker(marker, this)) {\n this.requestSync();\n return false;\n }\n\n marker.setActive(true);\n this._activeMarker = marker;\n }\n\n this.requestSync();\n return true;\n }\n\n /** @internal */\n public readonly useCachedDecorations = true;\n\n /** @internal */\n public decorate(context: DecorateContext): void {\n if (this.viewport.view.is3d())\n this.markers.addDecoration(context);\n }\n\n private constructor(markers: SectionMarkerSet, config: SectionMarkerConfig) {\n this.markers = markers;\n this._config = { ...config };\n this._iModel = this.viewport.iModel;\n\n this.viewport.onChangeView.addOnce(() => {\n this.requestSync();\n });\n\n this._removeEventListeners.push(this.viewport.onViewportChanged.addListener((_, changeFlags) => this.onViewportChanged(changeFlags)));\n this._removeEventListeners.push(this.viewport.onDisposed.addListener(() => this[Symbol.dispose]()));\n\n for (const marker of markers.markers) {\n marker.onMouseEnterEvent.addListener((mkr) => this.showToolbarAfterTimeout(mkr));\n marker.onMouseButtonEvent.addListener((mkr) => this.toggleMarker(mkr)); // eslint-disable-line @typescript-eslint/promise-function-async\n }\n\n this.updateMarkerVisibility();\n IModelApp.viewManager.addDecorator(this);\n }\n\n private onViewportChanged(changeFlags: ChangeFlags): void {\n if (this.viewport.iModel !== this._iModel) {\n this[Symbol.dispose]();\n return;\n }\n\n if (changeFlags.viewedCategories || changeFlags.viewedModels || changeFlags.viewedCategoriesPerModel)\n this.requestSync();\n\n if (changeFlags.viewState) {\n // If we're looking at a different view now, and we did not initiate that, turn off the active marker.\n if (this.viewport.view !== this._appliedSpatialView)\n this.setActiveMarker(undefined); // eslint-disable-line @typescript-eslint/no-floating-promises\n else\n this._appliedSpatialView = undefined;\n }\n }\n\n private async toggleMarker(marker: SectionMarker): Promise<void> {\n await this.setActiveMarker(marker === this.activeMarker ? undefined : marker);\n }\n\n private dropTiledGraphicsProvider(): void {\n if (undefined === this._tiledGraphicsProvider)\n return;\n\n this.viewport.dropTiledGraphicsProvider(this._tiledGraphicsProvider);\n this._tiledGraphicsProvider = undefined;\n }\n\n /** @internal */\n public [Symbol.dispose](): void {\n if (!IModelApp.viewManager.dropDecorator(this))\n return;\n\n for (const remove of this._removeEventListeners)\n remove();\n\n this.dropTiledGraphicsProvider();\n }\n\n private showToolbarAfterTimeout(marker: SectionMarker): void {\n if (this._toolbarProvider?.marker !== marker)\n this._toolbarProvider = new MarkerToolbarProvider(marker, this);\n\n PopupToolbarManager.showToolbarAfterTimeout(this._toolbarProvider);\n }\n\n /** Toggles whether the clip volume associated with the specified marker is applied to the view. */\n public toggleClipVolume(marker: SectionMarker, enable: boolean): void {\n ViewClipTool.enableClipVolume(this.viewport);\n ViewClipTool.setViewClip(this.viewport, enable ? marker.state.clip : undefined);\n }\n\n /** Toggles the specified section marker.\n * Enabling the section applies the frustum and clip volume of the marker's spatial view to the viewport, and displays the 2d section graphics and sheet annotations.\n * Disabling the section disables the clip volume and 2d graphics.\n * @see [[toggleClipVolume]] to toggle only the clip volume.\n * @see [[toggleAttachment]] to toggle only the attachment graphics.\n */\n public async toggleSection(marker: SectionMarker, enable: boolean): Promise<boolean> {\n if (enable) {\n if (this.viewport.view.is3d()) {\n // Preserve the view settings; apply only the frustum and clip volume\n const spatialView = await marker.state.tryLoadSpatialView();\n if (!spatialView)\n return false;\n\n const aligned = await this.alignToSpatialView(marker);\n if (!aligned)\n return false;\n\n this.toggleClipVolume(marker, true);\n } else if (!await this.applySpatialView(marker)) {\n return false;\n }\n } else {\n this.toggleClipVolume(marker, false);\n }\n\n this.requestSync();\n return this.toggleAttachment(marker, enable);\n }\n\n /** Toggles display of 2d section graphics and sheet annotations for the specified marker.\n * @see [[toggleSection]] to apply the spatial view and clip volume in addition to the attachment graphics.\n */\n public async toggleAttachment(marker: SectionMarker, enable: boolean): Promise<boolean> {\n this.dropTiledGraphicsProvider();\n if (enable) {\n this._tiledGraphicsProvider = await createSectionGraphicsProvider(marker.state);\n this.viewport.addTiledGraphicsProvider(this._tiledGraphicsProvider);\n }\n\n return true;\n }\n\n /** Aligns the viewport to face the specified marker's section plane. */\n public alignView(marker: SectionMarker): void {\n const placement = marker.state.placement.transform;\n const origin = placement.origin;\n const matrix = placement.matrix;\n\n const vp = this.viewport;\n const targetMatrix = matrix.multiplyMatrixMatrix(vp.rotation);\n const rotateTransform = Transform.createFixedPointAndMatrix(origin, targetMatrix);\n\n const startFrustum = vp.getFrustum();\n const newFrustum = startFrustum.clone();\n newFrustum.multiply(rotateTransform);\n\n if (startFrustum.equals(newFrustum))\n return;\n\n vp.view.setupFromFrustum(newFrustum);\n vp.synchWithView();\n vp.animateFrustumChange();\n }\n\n /** Opens the marker's drawing view in the decorator's viewport. Returns false if the drawing view could not be loaded. */\n public async openSection(marker: SectionMarker): Promise<boolean> {\n const viewState = await marker.state.tryLoadDrawingView();\n if (viewState)\n this.viewport.changeView(viewState);\n\n return undefined !== viewState;\n }\n\n /** Opens marker's sheet view in the decorator's viewport and zooms in on the associated [ViewAttachment]($backend). Returns false if no view\n * attachment exists or the sheet view could not be loaded.\n */\n public async openSheet(marker: SectionMarker): Promise<boolean> {\n if (undefined === marker.state.viewAttachment)\n return false;\n\n const viewState = await marker.state.tryLoadSheetView();\n if (!viewState)\n return false;\n\n this.viewport.changeView(viewState);\n await this.viewport.zoomToElements(marker.state.viewAttachment.id);\n return true;\n }\n\n /** Aligns the view to match the frustum of the spatial view associated with the specified marker.\n * @param marker The marker whose spatial view's frustum should be applied.\n * @returns false if the frustum could not be applied, e.g. because the spatial view could not be loaded or the viewport is viewing a 2d model.\n * @see [[alignView]] to align to the *section plane*, which may differ.\n * @see [[toggleSection]] to also apply the clip volume.\n */\n public async alignToSpatialView(marker: SectionMarker): Promise<boolean> {\n if (!this.viewport.view.is3d())\n return false;\n\n const spatialView = await marker.state.tryLoadSpatialView();\n if (!spatialView)\n return false;\n\n this.viewport.view.setOrigin(spatialView.getOrigin());\n this.viewport.view.setExtents(spatialView.getExtents());\n this.viewport.view.setRotation(spatialView.getRotation());\n this.viewport.synchWithView({ animateFrustumChange: true });\n\n return true;\n }\n\n /** Applies the marker's spatial view - including its clip volume - to the decorator's viewport.\n * Returns false if the spatial view could not be loaded.\n * @see [[toggleSection]].\n * @see [[toggleClipVolume]].\n */\n public async applySpatialView(marker: SectionMarker): Promise<boolean> {\n const viewState = await marker.state.tryLoadSpatialView();\n if (viewState) {\n this._appliedSpatialView = viewState;\n this.viewport.changeView(viewState);\n }\n\n return undefined !== viewState;\n }\n\n /** Request that the visibility of the section markers be recomputed. It is only necessary to call this if you have overridden [[SectionMarkerHandler.isMarkerVisible]]; if so, you should invoke\n * this method when the criteria governing your `isMarkerVisible` method have changed.\n */\n public requestSync(): void {\n if (this.syncImmediately) {\n this.sync();\n } else if (!this._needSync) {\n this._needSync = true;\n requestAnimationFrame(() => this.sync());\n }\n }\n\n private sync(): void {\n this._needSync = false;\n if (HyperModeling.isInitialized && this.viewport.view.is3d() && this.updateMarkerVisibility()) {\n this.markers.markDirty();\n this.viewport.invalidateCachedDecorations(this);\n }\n }\n\n private isMarkerVisible(marker: SectionMarker): boolean {\n if (undefined !== this.activeMarker)\n return marker === this.activeMarker;\n\n return HyperModeling.markerHandler.isMarkerVisible(marker, this, this._config);\n }\n\n private updateMarkerVisibility(): boolean {\n let changed = false;\n for (const marker of this.markers.markers) {\n const wasVisible = marker.visible;\n marker.visible = this.isMarkerVisible(marker);\n changed = changed || (marker.visible !== wasVisible);\n }\n\n return changed;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"HyperModelingDecorator.js","sourceRoot":"","sources":["../../src/HyperModelingDecorator.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAS,MAAM,sBAAsB,CAAC;AAExD,OAAO,EACoC,SAAS,EAA6E,YAAY,GAC5I,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAwB,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,KAAK,UAAU,aAAa,CAAC,EAAkB;IAC7C,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE;QAC1B,OAAO,SAAS,CAAC;IAEnB,MAAM,MAAM,GAAG,MAAM,2BAA2B,CAAC,QAAQ,CAAC,EAAE,CAAC,MA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C,OAAO,CAAC,CAAC;IACjF,CAAC;IAEO,sBAAsB;QAC5B,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YAC1C,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC;YAClC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;YAC9C,OAAO,GAAG,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC;QACvD,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,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 { Transform, XAndY } from \"@itwin/core-geometry\";\nimport type { AbstractToolbarProps } from \"@itwin/appui-abstract\";\nimport {\n ChangeFlags, DecorateContext, Decorator, IModelApp, IModelConnection, ScreenViewport, SpatialViewState, TiledGraphicsProvider, ViewClipTool,\n} from \"@itwin/core-frontend\";\nimport { SectionMarker, SectionMarkerSet } from \"./SectionMarkers\";\nimport { SectionDrawingLocationState } from \"./SectionDrawingLocationState\";\nimport { createSectionGraphicsProvider } from \"./SectionGraphicsProvider\";\nimport { PopupToolbarManager, PopupToolbarProvider } from \"./PopupToolbar\";\nimport { HyperModeling } from \"./HyperModeling\";\nimport { SectionMarkerConfig } from \"./HyperModelingConfig\";\n\nasync function createMarkers(vp: ScreenViewport): Promise<SectionMarkerSet | undefined> {\n if (!vp.view.isSpatialView())\n return undefined;\n\n const states = await SectionDrawingLocationState.queryAll(vp.iModel);\n if (0 === states.length)\n return undefined;\n\n const markers = states.map((state) => new SectionMarker(state));\n return new SectionMarkerSet(vp, markers);\n}\n\nclass MarkerToolbarProvider implements PopupToolbarProvider {\n private readonly _viewport: ScreenViewport;\n public readonly marker: SectionMarker;\n public readonly toolbarProps: AbstractToolbarProps;\n public readonly onToolbarItemExecuted: (id: string) => void;\n\n public constructor(marker: SectionMarker, decorator: HyperModelingDecorator) {\n this.marker = marker;\n this._viewport = decorator.viewport;\n this.toolbarProps = HyperModeling.markerHandler.getToolbarProps(marker, decorator);\n this.onToolbarItemExecuted = (id) => HyperModeling.markerHandler.executeCommand(id, marker, decorator); // eslint-disable-line @typescript-eslint/promise-function-async\n }\n\n public get overToolbarHotspot() {\n return this.marker.isHilited;\n }\n\n public get toolbarLocation(): XAndY {\n return { x: this.marker.rect.right, y: this.marker.rect.top };\n }\n\n public get htmlElement() {\n return this._viewport.canvas;\n }\n}\n\n/** A [Decorator]($frontend) that displays a [[SectionMarker]] for each [SectionDrawingLocation]($backend) in the view.\n * Clicking on a marker toggles the section and the display of associated 2d graphics.\n * Hovering over a marker opens a mini toolbar with additional interactions.\n * @see [[SectionMarkerHandler]] to customize the marker interactions.\n * @see [[HyperModeling.startOrStop]] to enable or disable the decorator for a viewport.\n * @public\n */\nexport class HyperModelingDecorator implements Decorator {\n /** The set of [[SectionMarker]]s controlled by this decorator. */\n public readonly markers: SectionMarkerSet;\n private _config: SectionMarkerConfig;\n private readonly _removeEventListeners = new Array<() => void>();\n private readonly _iModel: IModelConnection;\n private _needSync = false;\n private _toolbarProvider?: MarkerToolbarProvider;\n private _tiledGraphicsProvider?: TiledGraphicsProvider;\n private _activeMarker?: SectionMarker;\n private _appliedSpatialView?: SpatialViewState;\n /** @internal */\n public syncImmediately = false;\n\n /** Create a new decorator and register it with the [ViewManager]($frontend). Typically invoked indirectly via [[HyperModeling.startOrStop]]. */\n public static async create(vp: ScreenViewport, config: SectionMarkerConfig): Promise<HyperModelingDecorator | undefined> {\n const markers = await createMarkers(vp);\n return undefined !== markers ? new HyperModelingDecorator(markers, config) : undefined;\n }\n\n /** Obtain the decorator associated with the specified viewport, if any. */\n public static getForViewport(vp: ScreenViewport): HyperModelingDecorator | undefined {\n for (const decorator of IModelApp.viewManager.decorators)\n if (decorator instanceof HyperModelingDecorator && decorator.viewport === vp)\n return decorator;\n\n return undefined;\n }\n\n /** The viewport into which this decorator draws its [[SectionMarker]]s. */\n public get viewport(): ScreenViewport {\n return this.markers.viewport;\n }\n\n /** The currently active marker. A marker typically becomes active when the user clicks on it.\n * @see [[setActiveMarker]] to change the active marker without user interaction.\n */\n public get activeMarker(): SectionMarker | undefined {\n return this._activeMarker;\n }\n\n /** @internal */\n public get config(): SectionMarkerConfig {\n return this._config;\n }\n\n /** Replaces the current marker display configuration, overwriting all previous settings. Passing `undefined` resets all settings to defaults.\n * @see [[updateConfiguration]] to override specific aspects of the configuration\n * @see [[HyperModeling.replaceConfiguration]] to replace the global configuration.\n */\n public replaceConfiguration(config?: SectionMarkerConfig): void {\n this._config = config ? { ...config } : {};\n this.requestSync();\n }\n\n /** Overrides specific aspects of the current marker display configuration.\n * Any field that is not `undefined` will be replaced in the current configuration; the rest will retain their current values.\n * @see [[replaceConfiguration]] to override all settings.\n * @see [[HyperModeling.updateConfiguration]] to update the global configuration.\n */\n public updateConfiguration(config: SectionMarkerConfig): void {\n this._config = {\n ignoreModelSelector: config.ignoreModelSelector ?? this._config.ignoreModelSelector,\n ignoreCategorySelector: config.ignoreCategorySelector ?? this._config.ignoreCategorySelector,\n hiddenSectionTypes: config.hiddenSectionTypes ?? this._config.hiddenSectionTypes,\n };\n\n this.requestSync();\n }\n\n /** Sets the currently active marker. This function is invoked when the user clicks on a marker, but may also be called manually to produce the same result.\n * Changing the active marker first deactivates the currently active marker, if any; then activates the specified marker, if supplied.\n * Returns false if marker activation fails.\n * @see [[activeMarker]] to obtain the currently active section marker.\n * @see [[SectionMarkerHandler.activateMarker]] to control what happens when a marker is activated.\n * @see [[SectionMarkerHandler.deactivateMarker]] to control what happens when a marker is deactivated.\n */\n public async setActiveMarker(marker: SectionMarker | undefined): Promise<boolean> {\n if (marker === this.activeMarker)\n return true;\n\n if (this.activeMarker) {\n this.activeMarker.setActive(false);\n await HyperModeling.markerHandler.deactivateMarker(this.activeMarker, this);\n this._activeMarker = undefined;\n }\n\n if (marker) {\n if (!await HyperModeling.markerHandler.activateMarker(marker, this)) {\n this.requestSync();\n return false;\n }\n\n marker.setActive(true);\n this._activeMarker = marker;\n }\n\n this.requestSync();\n return true;\n }\n\n /** @internal */\n public readonly useCachedDecorations = true;\n\n /** @internal */\n public decorate(context: DecorateContext): void {\n if (this.viewport.view.is3d())\n this.markers.addDecoration(context);\n }\n\n private constructor(markers: SectionMarkerSet, config: SectionMarkerConfig) {\n this.markers = markers;\n this._config = { ...config };\n this._iModel = this.viewport.iModel;\n\n this.viewport.onChangeView.addOnce(() => {\n this.requestSync();\n });\n\n this._removeEventListeners.push(this.viewport.onViewportChanged.addListener((_, changeFlags) => this.onViewportChanged(changeFlags)));\n this._removeEventListeners.push(this.viewport.onDisposed.addListener(() => this[Symbol.dispose]()));\n\n for (const marker of markers.markers) {\n marker.onMouseEnterEvent.addListener((mkr) => this.showToolbarAfterTimeout(mkr));\n marker.onMouseButtonEvent.addListener((mkr) => this.toggleMarker(mkr)); // eslint-disable-line @typescript-eslint/promise-function-async\n }\n\n this.updateMarkerVisibility();\n IModelApp.viewManager.addDecorator(this);\n }\n\n private onViewportChanged(changeFlags: ChangeFlags): void {\n if (this.viewport.iModel !== this._iModel) {\n this[Symbol.dispose]();\n return;\n }\n\n if (changeFlags.viewedCategories || changeFlags.viewedModels || changeFlags.viewedCategoriesPerModel)\n this.requestSync();\n\n if (changeFlags.viewState) {\n // If we're looking at a different view now, and we did not initiate that, turn off the active marker.\n if (this.viewport.view !== this._appliedSpatialView)\n this.setActiveMarker(undefined); // eslint-disable-line @typescript-eslint/no-floating-promises\n else\n this._appliedSpatialView = undefined;\n }\n }\n\n private async toggleMarker(marker: SectionMarker): Promise<void> {\n await this.setActiveMarker(marker === this.activeMarker ? undefined : marker);\n }\n\n private dropTiledGraphicsProvider(): void {\n if (undefined === this._tiledGraphicsProvider)\n return;\n\n this.viewport.dropTiledGraphicsProvider(this._tiledGraphicsProvider);\n this._tiledGraphicsProvider = undefined;\n }\n\n /** @internal */\n public [Symbol.dispose](): void {\n if (!IModelApp.viewManager.dropDecorator(this))\n return;\n\n for (const remove of this._removeEventListeners)\n remove();\n\n this.dropTiledGraphicsProvider();\n }\n\n private showToolbarAfterTimeout(marker: SectionMarker): void {\n if (this._toolbarProvider?.marker !== marker)\n this._toolbarProvider = new MarkerToolbarProvider(marker, this);\n\n PopupToolbarManager.showToolbarAfterTimeout(this._toolbarProvider);\n }\n\n /** Toggles whether the clip volume associated with the specified marker is applied to the view. */\n public toggleClipVolume(marker: SectionMarker, enable: boolean): void {\n ViewClipTool.enableClipVolume(this.viewport);\n ViewClipTool.setViewClip(this.viewport, enable ? marker.state.clip : undefined);\n }\n\n /** Toggles the specified section marker.\n * Enabling the section applies the frustum and clip volume of the marker's spatial view to the viewport, and displays the 2d section graphics and sheet annotations.\n * Disabling the section disables the clip volume and 2d graphics.\n * @see [[toggleClipVolume]] to toggle only the clip volume.\n * @see [[toggleAttachment]] to toggle only the attachment graphics.\n */\n public async toggleSection(marker: SectionMarker, enable: boolean): Promise<boolean> {\n if (enable) {\n if (this.viewport.view.is3d()) {\n // Preserve the view settings; apply only the frustum and clip volume\n const spatialView = await marker.state.tryLoadSpatialView();\n if (!spatialView)\n return false;\n\n const aligned = await this.alignToSpatialView(marker);\n if (!aligned)\n return false;\n\n this.toggleClipVolume(marker, true);\n } else if (!await this.applySpatialView(marker)) {\n return false;\n }\n } else {\n this.toggleClipVolume(marker, false);\n }\n\n this.requestSync();\n return this.toggleAttachment(marker, enable);\n }\n\n /** Toggles display of 2d section graphics and sheet annotations for the specified marker.\n * @see [[toggleSection]] to apply the spatial view and clip volume in addition to the attachment graphics.\n */\n public async toggleAttachment(marker: SectionMarker, enable: boolean): Promise<boolean> {\n this.dropTiledGraphicsProvider();\n if (enable) {\n this._tiledGraphicsProvider = await createSectionGraphicsProvider(marker.state);\n this.viewport.addTiledGraphicsProvider(this._tiledGraphicsProvider);\n }\n\n return true;\n }\n\n /** Aligns the viewport to face the specified marker's section plane. */\n public alignView(marker: SectionMarker): void {\n const placement = marker.state.placement.transform;\n const origin = placement.origin;\n const matrix = placement.matrix;\n\n const vp = this.viewport;\n const targetMatrix = matrix.multiplyMatrixMatrix(vp.rotation);\n const rotateTransform = Transform.createFixedPointAndMatrix(origin, targetMatrix);\n\n const startFrustum = vp.getFrustum();\n const newFrustum = startFrustum.clone();\n newFrustum.multiply(rotateTransform);\n\n if (startFrustum.equals(newFrustum))\n return;\n\n vp.view.setupFromFrustum(newFrustum);\n vp.synchWithView();\n vp.animateFrustumChange();\n }\n\n /** Opens the marker's drawing view in the decorator's viewport. Returns false if the drawing view could not be loaded. */\n public async openSection(marker: SectionMarker): Promise<boolean> {\n const viewState = await marker.state.tryLoadDrawingView();\n if (viewState)\n this.viewport.changeView(viewState);\n\n return undefined !== viewState;\n }\n\n /** Opens marker's sheet view in the decorator's viewport and zooms in on the associated [ViewAttachment]($backend). Returns false if no view\n * attachment exists or the sheet view could not be loaded.\n */\n public async openSheet(marker: SectionMarker): Promise<boolean> {\n if (undefined === marker.state.viewAttachment)\n return false;\n\n const viewState = await marker.state.tryLoadSheetView();\n if (!viewState)\n return false;\n\n this.viewport.changeView(viewState);\n await this.viewport.zoomToElements(marker.state.viewAttachment.id);\n return true;\n }\n\n /** Aligns the view to match the frustum of the spatial view associated with the specified marker.\n * @param marker The marker whose spatial view's frustum should be applied.\n * @returns false if the frustum could not be applied, e.g. because the spatial view could not be loaded or the viewport is viewing a 2d model.\n * @see [[alignView]] to align to the *section plane*, which may differ.\n * @see [[toggleSection]] to also apply the clip volume.\n */\n public async alignToSpatialView(marker: SectionMarker): Promise<boolean> {\n if (!this.viewport.view.is3d())\n return false;\n\n const spatialView = await marker.state.tryLoadSpatialView();\n if (!spatialView)\n return false;\n\n this.viewport.view.setOrigin(spatialView.getOrigin());\n this.viewport.view.setExtents(spatialView.getExtents());\n this.viewport.view.setRotation(spatialView.getRotation());\n this.viewport.synchWithView({ animateFrustumChange: true });\n\n return true;\n }\n\n /** Applies the marker's spatial view - including its clip volume - to the decorator's viewport.\n * Returns false if the spatial view could not be loaded.\n * @see [[toggleSection]].\n * @see [[toggleClipVolume]].\n */\n public async applySpatialView(marker: SectionMarker): Promise<boolean> {\n const viewState = await marker.state.tryLoadSpatialView();\n if (viewState) {\n this._appliedSpatialView = viewState;\n this.viewport.changeView(viewState);\n }\n\n return undefined !== viewState;\n }\n\n /** Request that the visibility of the section markers be recomputed. It is only necessary to call this if you have overridden [[SectionMarkerHandler.isMarkerVisible]]; if so, you should invoke\n * this method when the criteria governing your `isMarkerVisible` method have changed.\n */\n public requestSync(): void {\n if (this.syncImmediately) {\n this.sync();\n } else if (!this._needSync) {\n this._needSync = true;\n requestAnimationFrame(() => this.sync());\n }\n }\n\n private sync(): void {\n this._needSync = false;\n if (HyperModeling.isInitialized && this.viewport.view.is3d() && this.updateMarkerVisibility()) {\n this.markers.markDirty();\n this.viewport.invalidateCachedDecorations(this);\n }\n }\n\n private isMarkerVisible(marker: SectionMarker): boolean {\n if (undefined !== this.activeMarker)\n return marker === this.activeMarker;\n\n return HyperModeling.markerHandler.isMarkerVisible(marker, this, this._config);\n }\n\n private updateMarkerVisibility(): boolean {\n let changed = false;\n for (const marker of this.markers.markers) {\n const wasVisible = marker.visible;\n marker.visible = this.isMarkerVisible(marker);\n changed = changed || (marker.visible !== wasVisible);\n }\n\n return changed;\n }\n}\n"]}
|
package/lib/esm/PopupToolbar.js
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
import { IModelApp } from "@itwin/core-frontend";
|
|
9
9
|
/** @internal */
|
|
10
10
|
export class PopupToolbarManager {
|
|
11
|
+
static _provider;
|
|
12
|
+
static _current;
|
|
11
13
|
static show() {
|
|
12
14
|
const prov = this._provider;
|
|
13
15
|
if (!prov || !prov.overToolbarHotspot)
|
|
@@ -20,17 +22,17 @@ export class PopupToolbarManager {
|
|
|
20
22
|
this.closeAfterTimeout();
|
|
21
23
|
return true;
|
|
22
24
|
}
|
|
23
|
-
static
|
|
25
|
+
static _itemExecuted = (item) => {
|
|
24
26
|
const mgr = PopupToolbarManager;
|
|
25
27
|
if (mgr._current)
|
|
26
28
|
mgr._current.onToolbarItemExecuted(item.id);
|
|
27
29
|
mgr.close();
|
|
28
|
-
};
|
|
29
|
-
static
|
|
30
|
+
};
|
|
31
|
+
static _cancel = () => {
|
|
30
32
|
const mgr = PopupToolbarManager;
|
|
31
33
|
if (!mgr._current || !mgr._current.overToolbarHotspot)
|
|
32
34
|
mgr.close(); // Don't hide when click is over hotspot
|
|
33
|
-
};
|
|
35
|
+
};
|
|
34
36
|
static close() {
|
|
35
37
|
this._current = undefined;
|
|
36
38
|
return IModelApp.uiAdmin.hideToolbar();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopupToolbar.js","sourceRoot":"","sources":["../../src/PopupToolbar.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAWjD,gBAAgB;AAChB,MAAM,OAAO,mBAAmB;
|
|
1
|
+
{"version":3,"file":"PopupToolbar.js","sourceRoot":"","sources":["../../src/PopupToolbar.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAWjD,gBAAgB;AAChB,MAAM,OAAO,mBAAmB;IACtB,MAAM,CAAC,SAAS,CAAwB;IACxC,MAAM,CAAC,QAAQ,CAAwB;IAEvC,MAAM,CAAC,IAAI;QACjB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC;QAC5B,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,kBAAkB;YACnC,OAAO,KAAK,CAAC;QAEf,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,C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AS,CAAC,SAAS,CAAC,UAAU;YACrE,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,kDAAkD;;YAErG,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAEM,MAAM,CAAC,uBAAuB,CAAC,QAA8B;QAClE,IAAI,IAAI,CAAC,QAAQ,KAAK,QAAQ;YAC5B,OAAO;QAET,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;IACrC,CAAC","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 { XAndY } from \"@itwin/core-geometry\";\nimport type { AbstractToolbarProps } from \"@itwin/appui-abstract\";\nimport { IModelApp } from \"@itwin/core-frontend\";\n\n/** @internal */\nexport interface PopupToolbarProvider {\n toolbarProps: AbstractToolbarProps;\n overToolbarHotspot: boolean;\n toolbarLocation: XAndY;\n htmlElement: HTMLElement | undefined;\n onToolbarItemExecuted(id: string): void;\n}\n\n/** @internal */\nexport class PopupToolbarManager {\n private static _provider?: PopupToolbarProvider;\n private static _current?: PopupToolbarProvider;\n\n private static show(): boolean {\n const prov = this._provider;\n if (!prov || !prov.overToolbarHotspot)\n return false;\n\n const admin = IModelApp.uiAdmin;\n if (!admin.showToolbar(prov.toolbarProps, prov.toolbarLocation, { x: 0, y: 0 }, this._itemExecuted, this._cancel, undefined, prov.htmlElement))\n return false;\n\n this._current = this._provider;\n this._provider = undefined;\n this.closeAfterTimeout();\n return true;\n }\n\n private static _itemExecuted = (item: any) => {\n const mgr = PopupToolbarManager;\n if (mgr._current)\n mgr._current.onToolbarItemExecuted(item.id);\n\n mgr.close();\n };\n\n private static _cancel = () => {\n const mgr = PopupToolbarManager;\n if (!mgr._current || !mgr._current.overToolbarHotspot)\n mgr.close(); // Don't hide when click is over hotspot\n };\n\n private static close(): boolean {\n this._current = undefined;\n return IModelApp.uiAdmin.hideToolbar();\n }\n\n private static closeAfterTimeout(): void {\n if (!this._current)\n return;\n\n const delay = 1000;\n if (this._current.overToolbarHotspot || !IModelApp.toolAdmin.cursorView)\n setTimeout(() => this.closeAfterTimeout(), delay); // Cursor not in view or over hotspot, check again\n else\n this.close();\n }\n\n public static showToolbarAfterTimeout(provider: PopupToolbarProvider): void {\n if (this._current === provider)\n return;\n\n this._provider = provider;\n setTimeout(() => this.show(), 500);\n }\n}\n"]}
|
|
@@ -43,6 +43,34 @@ const selectSectionDrawingLocationStatesECSql = `
|
|
|
43
43
|
* @public
|
|
44
44
|
*/
|
|
45
45
|
export class SectionDrawingLocationState {
|
|
46
|
+
/** The iModel in which this section drawing location resides. */
|
|
47
|
+
iModel;
|
|
48
|
+
/** The element Id of the section drawing location. */
|
|
49
|
+
id;
|
|
50
|
+
/** The Id of the [GeometricModel3d]($backend) in which this section drawing location resides. */
|
|
51
|
+
model;
|
|
52
|
+
/** A user-friendly label for the section drawing location. */
|
|
53
|
+
userLabel;
|
|
54
|
+
/** The Id of the [SpatialCategory]($backend) to which this section drawing location belongs. */
|
|
55
|
+
category;
|
|
56
|
+
/** The section drawing location's spatial placement. */
|
|
57
|
+
placement;
|
|
58
|
+
/** The type of section that generated the associated [SectionDrawing]($backend). */
|
|
59
|
+
sectionType;
|
|
60
|
+
/** The Id of the [ViewDefinition]($backend) that can display the section graphics. */
|
|
61
|
+
drawingViewId;
|
|
62
|
+
/** The Id of the [SpatialViewDefinition]($backend) from which the section drawing was generated. */
|
|
63
|
+
spatialViewId;
|
|
64
|
+
/** The section clip from the [SpatialViewDefinition]($backend) from which the section drawing was generated. */
|
|
65
|
+
clip;
|
|
66
|
+
/** The transform from the [GeometricModel]($backend) containing the section graphics to the spatial coordinate space.
|
|
67
|
+
* This is used to position the 2d graphics in the context of a spatial view.
|
|
68
|
+
*/
|
|
69
|
+
drawingToSpatialTransform;
|
|
70
|
+
/** If the section drawing is attached to a [Sheet]($backend), details about the corresponding [ViewAttachment]($backend).
|
|
71
|
+
* When this section drawing location is displayed in a spatial context, annotations in the sheet model can be displayed along with the section graphics.
|
|
72
|
+
*/
|
|
73
|
+
viewAttachment;
|
|
46
74
|
/** @internal */
|
|
47
75
|
constructor(props, iModel) {
|
|
48
76
|
this.iModel = iModel;
|