@itwin/hypermodeling-frontend 4.10.0-dev.9 → 4.10.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"SectionMarkers.js","sourceRoot":"","sources":["../../src/SectionMarkers.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAkE;AAClE,wDAAuE;AACvE,oDAA4D;AAC5D,wDAE8B;AAE9B,mDAAgD;AAEhD,MAAM,UAAU,GAAG,uBAAO,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAE1C;;;;;GAKG;AACH,MAAa,aAAc,SAAQ,sBAAM;IAYvC;;;;;;OAMG;IACH,YAAmB,KAAkC;QACnD,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,UAAU,CAAC,CAAC;QAfpD,gBAAgB;QACA,sBAAiB,GAAG,IAAI,sBAAO,EAAmC,CAAC;QACnF,gBAAgB;QACA,uBAAkB,GAAG,IAAI,sBAAO,EAAmC,CAAC;QACpF,gBAAgB;QACR,cAAS,GAAG,KAAK,CAAC;QAWxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAEnB,MAAM,IAAI,GAAG,6BAAa,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC5D,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC;QAC9B,IAAI,IAAI,CAAC,KAAK;YACZ,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAE5B,IAAI,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,kFAAkF;IACjI,CAAC;IAED,gBAAgB;IAChB,IAAW,SAAS,KAAc,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IAE3D;;;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AI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,6DAA6D;IAC7D,IAAoB,QAAQ;QAC1B,IAAA,qBAAM,EAAC,SAAS,KAAK,KAAK,CAAC,QAAQ,CAAC,CAAC;QACrC,OAAO,KAAK,CAAC,QAAQ,CAAC;IACxB,CAAC;IAED,gBAAgB;IACN,gBAAgB,CAAC,OAA+B;QACxD,OAAO,IAAI,oBAAoB,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC5H,CAAC;IAED,mGAAmG;IAC5F,cAAc,CAAC,wBAAoC;QACxD,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO;YAC/B,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,wBAAwB;gBAC9C,OAAO,MAAM,CAAC;QAElB,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAnCD,4CAmCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module HyperModeling\r\n */\r\n\r\nimport { assert, BeEvent, Id64String } from \"@itwin/core-bentley\";\r\nimport { Point2d, Point3d, XAndY, XYAndZ } from \"@itwin/core-geometry\";\r\nimport { IModelReadRpcInterface } from \"@itwin/core-common\";\r\nimport {\r\n BeButton, BeButtonEvent, Cluster, DecorateContext, IModelApp, InputSource, Marker, MarkerImage, MarkerSet, ScreenViewport, ViewClipTool,\r\n} from \"@itwin/core-frontend\";\r\nimport { SectionDrawingLocationState } from \"./SectionDrawingLocationState\";\r\nimport { HyperModeling } from \"./HyperModeling\";\r\n\r\nconst markerSize = Point2d.create(40, 40);\r\n\r\n/** A [Marker]($frontend) associated with a [[SectionDrawingLocationState]], displayed as a canvas decoration at the location of the section.\r\n * Clicking on the marker toggles display of the section graphics. Mousing over the marker produces a toolbar with additional interactions.\r\n * @see [[HyperModelingDecorator]] for a [Decorator]($frontend) capable of displaying section markers for each section drawing location.\r\n * @see [[SectionMarkerHandler]] to customize the marker interactions.\r\n * @public\r\n */\r\nexport class SectionMarker extends Marker {\r\n /** The section drawing location state associated with the marker. */\r\n public readonly state: SectionDrawingLocationState;\r\n /** A description displayed as part of the tooltip when this marker is clustered with other markers. */\r\n public readonly description: string;\r\n /** @internal */\r\n public readonly onMouseEnterEvent = new BeEvent<(marker: SectionMarker) => void>();\r\n /** @internal */\r\n public readonly onMouseButtonEvent = new BeEvent<(marker: SectionMarker) => void>();\r\n /** @internal */\r\n private _isActive = false;\r\n\r\n /** Constructor, typically invoked indirectly via [[HyperModelingDecorator]].\r\n * @param state The section drawing location state this marker will represent.\r\n * @param pos The world coordinates at which to display the marker.\r\n * @param description A brief description of this marker, used as part of the tooltip when this marker is part of a cluster.\r\n * @param icon The icon displayed by the marker.\r\n * @param tooltip Optional detailed tooltip displayed on mouse hover. If undefined, the `description` is used instead.\r\n */\r\n public constructor(state: SectionDrawingLocationState) {\r\n super(state.placement.origin.clone(), markerSize);\r\n this.state = state;\r\n\r\n const data = HyperModeling.getMarkerData(state.sectionType);\r\n this.description = data.label;\r\n if (data.image)\r\n this.setImage(data.image);\r\n\r\n this.setScaleFactor({ low: .2, high: 1.4 }); // make size 20% at back of frustum and 140% at front of frustum (if camera is on)\r\n }\r\n\r\n /** @internal */\r\n public get isHilited(): boolean { return this._isHilited; }\r\n\r\n /** Returns true if this is the \"active\" section marker. At most one marker is active at a given time.\r\n * @see [[HyperModelingDecorator.activeMarker]].\r\n * @see [[HyperModelingDecorator.setActiveMarker]].\r\n * @see [[SectionMarkerHandler.toggleMarker]].\r\n */\r\n public get isActive(): boolean {\r\n return this._isActive;\r\n }\r\n\r\n /** @internal */\r\n public setActive(active: boolean): void {\r\n this._isActive = active;\r\n }\r\n\r\n /** @internal */\r\n protected drawActive(ctx: CanvasRenderingContext2D) {\r\n ctx.shadowBlur = 30;\r\n ctx.shadowColor = \"gold\";\r\n return false;\r\n }\r\n\r\n /** @internal */\r\n public override drawDecoration(ctx: CanvasRenderingContext2D): void {\r\n if (!this.isActive || !this.drawActive(ctx))\r\n super.drawDecoration(ctx);\r\n }\r\n\r\n /** @internal */\r\n public override onMouseEnter(ev: BeButtonEvent) {\r\n // Lazily load the tooltip.\r\n if (undefined === this.title) {\r\n IModelReadRpcInterface.getClientForRouting(this.state.iModel.routingContext.token).getToolTipMessage(this.state.iModel.getRpcProps(), this.state.id).then((tooltipMsg) => {\r\n this.title = IModelApp.formatElementToolTip(tooltipMsg);\r\n }).catch((_) => {\r\n this.title = this.description;\r\n });\r\n }\r\n\r\n super.onMouseEnter(ev);\r\n this.onMouseEnterEvent.raiseEvent(this);\r\n }\r\n\r\n /** @internal */\r\n public override onMouseButton(ev: BeButtonEvent): boolean {\r\n if (InputSource.Mouse === ev.inputSource && BeButton.Data === ev.button && ev.isDown && ev.viewport)\r\n this.onMouseButtonEvent.raiseEvent(this);\r\n\r\n return true; // Don't allow clicks to be sent to active tool...\r\n }\r\n\r\n /** @internal */\r\n public override addMarker(context: DecorateContext) {\r\n super.addMarker(context);\r\n if (this.isHilited)\r\n ViewClipTool.drawClip(context, this.state.clip, undefined, { fillClipPlanes: true, hasPrimaryPlane: true });\r\n }\r\n}\r\n\r\n/** A Marker used to show a cluster of section locations.\r\n * @internal\r\n */\r\nexport class SectionMarkerCluster extends Marker {\r\n /** Create a new cluster marker */\r\n constructor(location: XYAndZ, size: XAndY, cluster: Cluster<SectionMarker>, image: MarkerImage | Promise<MarkerImage> | undefined) {\r\n super(location, size);\r\n\r\n this.imageOffset = new Point3d(0, 30);\r\n this.label = cluster.markers.length.toLocaleString();\r\n this.labelColor = \"black\";\r\n this.labelFont = \"bold 14px sans-serif\";\r\n\r\n const maxLen = 10;\r\n let title = \"\";\r\n cluster.markers.forEach((marker, index: number) => {\r\n if (index < maxLen) {\r\n if (title !== \"\")\r\n title += \"<br>\";\r\n title += marker.description;\r\n }\r\n });\r\n\r\n if (cluster.markers.length > maxLen)\r\n title += \"<br>...\";\r\n\r\n const div = document.createElement(\"div\");\r\n div.innerHTML = title;\r\n this.title = div;\r\n if (image)\r\n this.setImage(image);\r\n }\r\n\r\n /** Show the cluster as a white circle with an outline */\r\n public override drawFunc(ctx: CanvasRenderingContext2D): void {\r\n ctx.beginPath();\r\n ctx.strokeStyle = \"#372528\";\r\n ctx.fillStyle = \"white\";\r\n ctx.lineWidth = 5;\r\n ctx.arc(0, 0, 13, 0, Math.PI * 2);\r\n ctx.fill();\r\n ctx.stroke();\r\n }\r\n\r\n public override onMouseButton(_ev: BeButtonEvent): boolean { return true; } // Don't allow clicks to be sent to active tool...\r\n}\r\n\r\n/** A [MarkerSet]($frontend) containing [[SectionMarker]]s identifying [SectionDrawingLocation]($backend)s within a spatial view.\r\n * Typically used indirectly via [[HyperModelingDecorator]].\r\n * @public\r\n */\r\nexport class SectionMarkerSet extends MarkerSet<SectionMarker> {\r\n public override minimumClusterSize = 5;\r\n\r\n /** Constructor\r\n * @param viewport The viewport in which the markers are to be displayed.\r\n * @param markers The markers to be displayed.\r\n * @note Each marker's [[SectionDrawingLocationState]] must be associated with the same [IModelConnection]($frontend) as the viewport; any markers from other iModels will be omitted.\r\n */\r\n public constructor(viewport: ScreenViewport, markers: SectionMarker[]) {\r\n super(viewport);\r\n for (const marker of markers) {\r\n if (marker.state.iModel === viewport.iModel)\r\n this.markers.add(marker);\r\n }\r\n }\r\n\r\n /** The viewport in which the markers are to be displayed. */\r\n public override get viewport(): ScreenViewport {\r\n assert(undefined !== super.viewport);\r\n return super.viewport;\r\n }\r\n\r\n /** @internal */\r\n protected getClusterMarker(cluster: Cluster<SectionMarker>): Marker {\r\n return new SectionMarkerCluster(cluster.getClusterLocation(), cluster.markers[0].size, cluster, cluster.markers[0].image);\r\n }\r\n\r\n /** Find the SectionMarker corresponding to the specified [SectionDrawingLocation]($backend) Id. */\r\n public findMarkerById(sectionDrawingLocationId: Id64String): SectionMarker | undefined {\r\n for (const marker of this.markers)\r\n if (marker.state.id === sectionDrawingLocationId)\r\n return marker;\r\n\r\n return undefined;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SectionMarkers.js","sourceRoot":"","sources":["../../src/SectionMarkers.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAkE;AAClE,wDAAuE;AACvE,oDAA4D;AAC5D,wDAE8B;AAE9B,mDAAgD;AAEhD,MAAM,UAAU,GAAG,uBAAO,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAE1C;;;;;GAKG;AACH,MAAa,aAAc,SAAQ,sBAAM;IAYvC;;;;;;OAMG;IACH,YAAmB,KAAkC;QACnD,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,UAAU,CAAC,CAAC;QAfpD,gBAAgB;QACA,sBAAiB,GAAG,IAAI,sBAAO,EAAmC,CAAC;QACnF,gBAAgB;QACA,uBAAkB,GAAG,IAAI,sBAAO,EAAmC,CAAC;QACpF,gBAAgB;QACR,cAAS,GAAG,KAAK,CAAC;QAWxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAEnB,MAAM,IAAI,GAAG,6BAAa,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC5D,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC;QAC9B,IAAI,IAAI,CAAC,KAAK;YACZ,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAE5B,IAAI,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,kFAAkF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IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM;gBACzC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,6DAA6D;IAC7D,IAAoB,QAAQ;QAC1B,IAAA,qBAAM,EAAC,SAAS,KAAK,KAAK,CAAC,QAAQ,CAAC,CAAC;QACrC,OAAO,KAAK,CAAC,QAAQ,CAAC;IACxB,CAAC;IAED,gBAAgB;IACN,gBAAgB,CAAC,OAA+B;QACxD,OAAO,IAAI,oBAAoB,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC5H,CAAC;IAED,mGAAmG;IAC5F,cAAc,CAAC,wBAAoC;QACxD,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO;YAC/B,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,wBAAwB;gBAC9C,OAAO,MAAM,CAAC;QAElB,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAnCD,4CAmCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module HyperModeling\n */\n\nimport { assert, BeEvent, Id64String } from \"@itwin/core-bentley\";\nimport { Point2d, Point3d, XAndY, XYAndZ } from \"@itwin/core-geometry\";\nimport { IModelReadRpcInterface } from \"@itwin/core-common\";\nimport {\n BeButton, BeButtonEvent, Cluster, DecorateContext, IModelApp, InputSource, Marker, MarkerImage, MarkerSet, ScreenViewport, ViewClipTool,\n} from \"@itwin/core-frontend\";\nimport { SectionDrawingLocationState } from \"./SectionDrawingLocationState\";\nimport { HyperModeling } from \"./HyperModeling\";\n\nconst markerSize = Point2d.create(40, 40);\n\n/** A [Marker]($frontend) associated with a [[SectionDrawingLocationState]], displayed as a canvas decoration at the location of the section.\n * Clicking on the marker toggles display of the section graphics. Mousing over the marker produces a toolbar with additional interactions.\n * @see [[HyperModelingDecorator]] for a [Decorator]($frontend) capable of displaying section markers for each section drawing location.\n * @see [[SectionMarkerHandler]] to customize the marker interactions.\n * @public\n */\nexport class SectionMarker extends Marker {\n /** The section drawing location state associated with the marker. */\n public readonly state: SectionDrawingLocationState;\n /** A description displayed as part of the tooltip when this marker is clustered with other markers. */\n public readonly description: string;\n /** @internal */\n public readonly onMouseEnterEvent = new BeEvent<(marker: SectionMarker) => void>();\n /** @internal */\n public readonly onMouseButtonEvent = new BeEvent<(marker: SectionMarker) => void>();\n /** @internal */\n private _isActive = false;\n\n /** Constructor, typically invoked indirectly via [[HyperModelingDecorator]].\n * @param state The section drawing location state this marker will represent.\n * @param pos The world coordinates at which to display the marker.\n * @param description A brief description of this marker, used as part of the tooltip when this marker is part of a cluster.\n * @param icon The icon displayed by the marker.\n * @param tooltip Optional detailed tooltip displayed on mouse hover. If undefined, the `description` is used instead.\n */\n public constructor(state: SectionDrawingLocationState) {\n super(state.placement.origin.clone(), markerSize);\n this.state = state;\n\n const data = HyperModeling.getMarkerData(state.sectionType);\n this.description = data.label;\n if (data.image)\n this.setImage(data.image);\n\n this.setScaleFactor({ low: .2, high: 1.4 }); // make size 20% at back of frustum and 140% at front of frustum (if camera is on)\n }\n\n /** @internal */\n public get isHilited(): boolean { return this._isHilited; }\n\n /** Returns true if this is the \"active\" section marker. At most one marker is active at a given time.\n * @see [[HyperModelingDecorator.activeMarker]].\n * @see [[HyperModelingDecorator.setActiveMarker]].\n * @see [[SectionMarkerHandler.toggleMarker]].\n */\n public get isActive(): boolean {\n return this._isActive;\n }\n\n /** @internal */\n public setActive(active: boolean): void {\n this._isActive = active;\n }\n\n /** @internal */\n protected drawActive(ctx: CanvasRenderingContext2D) {\n ctx.shadowBlur = 30;\n ctx.shadowColor = \"gold\";\n return false;\n }\n\n /** @internal */\n public override drawDecoration(ctx: CanvasRenderingContext2D): void {\n if (!this.isActive || !this.drawActive(ctx))\n super.drawDecoration(ctx);\n }\n\n /** @internal */\n public override onMouseEnter(ev: BeButtonEvent) {\n // Lazily load the tooltip.\n if (undefined === this.title) {\n IModelReadRpcInterface.getClientForRouting(this.state.iModel.routingContext.token).getToolTipMessage(this.state.iModel.getRpcProps(), this.state.id).then((tooltipMsg) => {\n this.title = IModelApp.formatElementToolTip(tooltipMsg);\n }).catch((_) => {\n this.title = this.description;\n });\n }\n\n super.onMouseEnter(ev);\n this.onMouseEnterEvent.raiseEvent(this);\n }\n\n /** @internal */\n public override onMouseButton(ev: BeButtonEvent): boolean {\n if (InputSource.Mouse === ev.inputSource && BeButton.Data === ev.button && ev.isDown && ev.viewport)\n this.onMouseButtonEvent.raiseEvent(this);\n\n return true; // Don't allow clicks to be sent to active tool...\n }\n\n /** @internal */\n public override addMarker(context: DecorateContext) {\n super.addMarker(context);\n if (this.isHilited)\n ViewClipTool.drawClip(context, this.state.clip, undefined, { fillClipPlanes: true, hasPrimaryPlane: true });\n }\n}\n\n/** A Marker used to show a cluster of section locations.\n * @internal\n */\nexport class SectionMarkerCluster extends Marker {\n /** Create a new cluster marker */\n constructor(location: XYAndZ, size: XAndY, cluster: Cluster<SectionMarker>, image: MarkerImage | Promise<MarkerImage> | undefined) {\n super(location, size);\n\n this.imageOffset = new Point3d(0, 30);\n this.label = cluster.markers.length.toLocaleString();\n this.labelColor = \"black\";\n this.labelFont = \"bold 14px sans-serif\";\n\n const maxLen = 10;\n let title = \"\";\n cluster.markers.forEach((marker, index: number) => {\n if (index < maxLen) {\n if (title !== \"\")\n title += \"<br>\";\n title += marker.description;\n }\n });\n\n if (cluster.markers.length > maxLen)\n title += \"<br>...\";\n\n const div = document.createElement(\"div\");\n div.innerHTML = title;\n this.title = div;\n if (image)\n this.setImage(image);\n }\n\n /** Show the cluster as a white circle with an outline */\n public override drawFunc(ctx: CanvasRenderingContext2D): void {\n ctx.beginPath();\n ctx.strokeStyle = \"#372528\";\n ctx.fillStyle = \"white\";\n ctx.lineWidth = 5;\n ctx.arc(0, 0, 13, 0, Math.PI * 2);\n ctx.fill();\n ctx.stroke();\n }\n\n public override onMouseButton(_ev: BeButtonEvent): boolean { return true; } // Don't allow clicks to be sent to active tool...\n}\n\n/** A [MarkerSet]($frontend) containing [[SectionMarker]]s identifying [SectionDrawingLocation]($backend)s within a spatial view.\n * Typically used indirectly via [[HyperModelingDecorator]].\n * @public\n */\nexport class SectionMarkerSet extends MarkerSet<SectionMarker> {\n public override minimumClusterSize = 5;\n\n /** Constructor\n * @param viewport The viewport in which the markers are to be displayed.\n * @param markers The markers to be displayed.\n * @note Each marker's [[SectionDrawingLocationState]] must be associated with the same [IModelConnection]($frontend) as the viewport; any markers from other iModels will be omitted.\n */\n public constructor(viewport: ScreenViewport, markers: SectionMarker[]) {\n super(viewport);\n for (const marker of markers) {\n if (marker.state.iModel === viewport.iModel)\n this.markers.add(marker);\n }\n }\n\n /** The viewport in which the markers are to be displayed. */\n public override get viewport(): ScreenViewport {\n assert(undefined !== super.viewport);\n return super.viewport;\n }\n\n /** @internal */\n protected getClusterMarker(cluster: Cluster<SectionMarker>): Marker {\n return new SectionMarkerCluster(cluster.getClusterLocation(), cluster.markers[0].size, cluster, cluster.markers[0].image);\n }\n\n /** Find the SectionMarker corresponding to the specified [SectionDrawingLocation]($backend) Id. */\n public findMarkerById(sectionDrawingLocationId: Id64String): SectionMarker | undefined {\n for (const marker of this.markers)\n if (marker.state.id === sectionDrawingLocationId)\n return marker;\n\n return undefined;\n }\n}\n"]}
package/lib/cjs/Tools.js CHANGED
@@ -7,7 +7,7 @@
7
7
  * @module HyperModeling
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.registerTools = void 0;
10
+ exports.registerTools = registerTools;
11
11
  const core_common_1 = require("@itwin/core-common");
12
12
  const core_frontend_1 = require("@itwin/core-frontend");
13
13
  const HyperModeling_1 = require("./HyperModeling");
@@ -167,5 +167,4 @@ function registerTools(namespace) {
167
167
  register(SectionMarkerDecoratorConfigTool);
168
168
  register(SectionMarkerDefaultConfigTool);
169
169
  }
170
- exports.registerTools = registerTools;
171
170
  //# sourceMappingURL=Tools.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tools.js","sourceRoot":"","sources":["../../src/Tools.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,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;IAE3B,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,CAAC,WAAW,CAAC,GAAG,IAAc;QACjD,M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,CAAC,sBAAsB,GAAG,CAAC,KAAK,MAAM,CAAC;6BAC1C,IAAI,GAAG,KAAK,OAAO;4BACtB,MAAM,CAAC,mBAAmB,GAAG,CAAC,KAAK,MAAM,CAAC;oBAC9C,CAAC;oBAED,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;CACF;AAED,MAAM,8BAA+B,SAAQ,uBAAuB;IAGxD,MAAM,CAAC,MAA2B;QAC1C,6BAAa,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IACzD,CAAC;;AAJsB,qCAAM,GAAG,qCAAqC,CAAC;AAOxE,MAAM,gCAAiC,SAAQ,uBAAuB;IAG1D,MAAM,CAAC,MAA2B;QAC1C,MAAM,EAAE,GAAG,yBAAS,CAAC,WAAW,CAAC,YAAY,CAAC;QAC9C,MAAM,SAAS,GAAG,EAAE,CAAC,CAAC,CAAC,+CAAsB,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC7E,IAAI,SAAS;YACX,SAAS,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;;AAPsB,uCAAM,GAAG,6BAA6B,CAAC;AAUhE,gBAAgB;AAChB,SAAgB,aAAa,CAAC,SAAiB;IAC7C,MAAM,QAAQ,GAAG,CAAC,IAAiB,EAAE,EAAE,CAAC,yBAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAClF,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAC5B,QAAQ,CAAC,yBAAyB,CAAC,CAAC;IACpC,QAAQ,CAAC,gCAAgC,CAAC,CAAC;IAC3C,QAAQ,CAAC,8BAA8B,CAAC,CAAC;AAC3C,CAAC;AAND,sCAMC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module HyperModeling\r\n */\r\n\r\nimport { SectionType } from \"@itwin/core-common\";\r\nimport { 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(SectionMarkerD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AAG,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;CACF;AAED,MAAM,8BAA+B,SAAQ,uBAAuB;IAGxD,MAAM,CAAC,MAA2B;QAC1C,6BAAa,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IACzD,CAAC;;AAJsB,qCAAM,GAAG,qCAAqC,CAAC;AAOxE,MAAM,gCAAiC,SAAQ,uBAAuB;IAG1D,MAAM,CAAC,MAA2B;QAC1C,MAAM,EAAE,GAAG,yBAAS,CAAC,WAAW,CAAC,YAAY,CAAC;QAC9C,MAAM,SAAS,GAAG,EAAE,CAAC,CAAC,CAAC,+CAAsB,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC7E,IAAI,SAAS;YACX,SAAS,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;;AAPsB,uCAAM,GAAG,6BAA6B,CAAC;AAUhE,gBAAgB;AAChB,SAAgB,aAAa,CAAC,SAAiB;IAC7C,MAAM,QAAQ,GAAG,CAAC,IAAiB,EAAE,EAAE,CAAC,yBAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAClF,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAC5B,QAAQ,CAAC,yBAAyB,CAAC,CAAC;IACpC,QAAQ,CAAC,gCAAgC,CAAC,CAAC;IAC3C,QAAQ,CAAC,8BAA8B,CAAC,CAAC;AAC3C,CAAC","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 +1 @@
1
- {"version":3,"file":"hypermodeling-frontend.js","sourceRoot":"","sources":["../../src/hypermodeling-frontend.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,kDAAgC;AAChC,wDAAsC;AACtC,2DAAyC;AACzC,yDAAuC;AACvC,gEAA8C;AAC9C,4DAA0C;AAC1C,mDAAiC;AAEjC;;GAEG;AAEH;;GAEG","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\nexport * from \"./HyperModeling\";\r\nexport * from \"./HyperModelingConfig\";\r\nexport * from \"./HyperModelingDecorator\";\r\nexport * from \"./SectionMarkerHandler\";\r\nexport * from \"./SectionDrawingLocationState\";\r\nexport * from \"./SectionGraphicsProvider\";\r\nexport * from \"./SectionMarkers\";\r\n\r\n/** @docs-package-description\r\n * The hypermodeling package enables visualization of section drawings in a spatial context.\r\n */\r\n\r\n/** @docs-group-description HyperModeling\r\n * APIs for controlling visualization of section drawings in a spatial context.\r\n */\r\n"]}
1
+ {"version":3,"file":"hypermodeling-frontend.js","sourceRoot":"","sources":["../../src/hypermodeling-frontend.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,kDAAgC;AAChC,wDAAsC;AACtC,2DAAyC;AACzC,yDAAuC;AACvC,gEAA8C;AAC9C,4DAA0C;AAC1C,mDAAiC;AAEjC;;GAEG;AAEH;;GAEG","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*--------------------------------------------------------------------------------------------*/\nexport * from \"./HyperModeling\";\nexport * from \"./HyperModelingConfig\";\nexport * from \"./HyperModelingDecorator\";\nexport * from \"./SectionMarkerHandler\";\nexport * from \"./SectionDrawingLocationState\";\nexport * from \"./SectionGraphicsProvider\";\nexport * from \"./SectionMarkers\";\n\n/** @docs-package-description\n * The hypermodeling package enables visualization of section drawings in a spatial context.\n */\n\n/** @docs-group-description HyperModeling\n * APIs for controlling visualization of section drawings in a spatial context.\n */\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"HyperModelingConfig.js","sourceRoot":"","sources":["../../src/HyperModelingConfig.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG","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 { SectionMarkerHandler } from \"./SectionMarkerHandler\";\r\n\r\n/** Configures display of [[SectionMarker]]s for [[HyperModelingDecorator]]s.\r\n * @see [[HyperModelingDecorator.updateConfiguration]] or [[HyperModelingDecorator.replaceConfiguration]] to change the configuration for a specific decorator.\r\n * @see [[HyperModeling.initialize]] to set the default configuration for all decorators at package initialization.\r\n * @see [[HyperModeling.updateConfiguration]] or [[HyperModeling.replaceConfiguration]] to change the default configuration for all subsequently created decorators.\r\n * @see [[HyperModelingConfig]].\r\n * @public\r\n */\r\nexport interface SectionMarkerConfig {\r\n /** Whether to hide markers belonging to models that are not present in the view's [ModelSelector]($backend). If true, markers are displayed regardless of their models. */\r\n readonly ignoreModelSelector?: boolean;\r\n /** Whether to hide markers belonging to categories that are not present in the view's [CategorySelector]($backend). If true, markers are displayed regardless of their categories. */\r\n readonly ignoreCategorySelector?: boolean;\r\n /** A list of types of section markers that shouold not be displayed. By default, markers for all section types are displayed. */\r\n readonly hiddenSectionTypes?: SectionType[];\r\n}\r\n\r\n/** Configures how 2d graphics are displayed by a [[HyperModelingDecorator]] when hypermodeling is active.\r\n * This configuration is used primarily for debugging, and applies globally to section graphics associated with all [[HyperModelingDecorator]]s.\r\n * @see [[HyperModeling.initialize]] to set this configuration at package initialization.\r\n * @see [[HyperModeling.updateConfiguration]] or [[HyperModeling.replaceConfiguration]] to change this configuration after package initialization.\r\n * @see [[HyperModelingConfig]].\r\n * @public\r\n */\r\nexport interface SectionGraphicsConfig {\r\n /** If true, 2d graphics will not be clipped. */\r\n readonly ignoreClip?: boolean;\r\n /** If true, clip volumes for 2d graphics are displayed as shapes. */\r\n readonly debugClipVolumes?: boolean;\r\n /** If true, [SectionDrawing]($backend) graphics will not be displayed.\r\n * @see [[hideSheetAnnotations]]\r\n */\r\n readonly hideSectionGraphics?: boolean;\r\n /** If true, [Sheet]($backend) annotation graphics will not be displayed.\r\n * @see [[hideSectionGraphics]]\r\n */\r\n readonly hideSheetAnnotations?: boolean;\r\n}\r\n\r\n/** Configuration options for the hyper-modeling package.\r\n * @see [[HyperModeling.initialize]] to set the configuration at package initialization.\r\n * @see [[HyperModeling.updateConfiguration]] or [[HyperModeling.replaceConfiguration]] to modify the configuration after package initialization.\r\n * @public\r\n */\r\nexport interface HyperModelingConfig {\r\n /** Specifies how the user interacts with [[SectionMarker]]s. If omitted, the default interactions will be used. */\r\n readonly markerHandler?: SectionMarkerHandler;\r\n /** Default [[SectionMarker]] display configuration used when creating a new [[HyperModelingDecorator]]. */\r\n readonly markers?: SectionMarkerConfig;\r\n /** Global section graphics configuration used by all [[HyperModelingDecorator]]s when displaying drawings and sheets in a spatial view. Primarily for debugging. */\r\n readonly graphics?: SectionGraphicsConfig;\r\n}\r\n"]}
1
+ {"version":3,"file":"HyperModelingConfig.js","sourceRoot":"","sources":["../../src/HyperModelingConfig.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG","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 { SectionType } from \"@itwin/core-common\";\nimport { SectionMarkerHandler } from \"./SectionMarkerHandler\";\n\n/** Configures display of [[SectionMarker]]s for [[HyperModelingDecorator]]s.\n * @see [[HyperModelingDecorator.updateConfiguration]] or [[HyperModelingDecorator.replaceConfiguration]] to change the configuration for a specific decorator.\n * @see [[HyperModeling.initialize]] to set the default configuration for all decorators at package initialization.\n * @see [[HyperModeling.updateConfiguration]] or [[HyperModeling.replaceConfiguration]] to change the default configuration for all subsequently created decorators.\n * @see [[HyperModelingConfig]].\n * @public\n */\nexport interface SectionMarkerConfig {\n /** Whether to hide markers belonging to models that are not present in the view's [ModelSelector]($backend). If true, markers are displayed regardless of their models. */\n readonly ignoreModelSelector?: boolean;\n /** Whether to hide markers belonging to categories that are not present in the view's [CategorySelector]($backend). If true, markers are displayed regardless of their categories. */\n readonly ignoreCategorySelector?: boolean;\n /** A list of types of section markers that shouold not be displayed. By default, markers for all section types are displayed. */\n readonly hiddenSectionTypes?: SectionType[];\n}\n\n/** Configures how 2d graphics are displayed by a [[HyperModelingDecorator]] when hypermodeling is active.\n * This configuration is used primarily for debugging, and applies globally to section graphics associated with all [[HyperModelingDecorator]]s.\n * @see [[HyperModeling.initialize]] to set this configuration at package initialization.\n * @see [[HyperModeling.updateConfiguration]] or [[HyperModeling.replaceConfiguration]] to change this configuration after package initialization.\n * @see [[HyperModelingConfig]].\n * @public\n */\nexport interface SectionGraphicsConfig {\n /** If true, 2d graphics will not be clipped. */\n readonly ignoreClip?: boolean;\n /** If true, clip volumes for 2d graphics are displayed as shapes. */\n readonly debugClipVolumes?: boolean;\n /** If true, [SectionDrawing]($backend) graphics will not be displayed.\n * @see [[hideSheetAnnotations]]\n */\n readonly hideSectionGraphics?: boolean;\n /** If true, [Sheet]($backend) annotation graphics will not be displayed.\n * @see [[hideSectionGraphics]]\n */\n readonly hideSheetAnnotations?: boolean;\n}\n\n/** Configuration options for the hyper-modeling package.\n * @see [[HyperModeling.initialize]] to set the configuration at package initialization.\n * @see [[HyperModeling.updateConfiguration]] or [[HyperModeling.replaceConfiguration]] to modify the configuration after package initialization.\n * @public\n */\nexport interface HyperModelingConfig {\n /** Specifies how the user interacts with [[SectionMarker]]s. If omitted, the default interactions will be used. */\n readonly markerHandler?: SectionMarkerHandler;\n /** Default [[SectionMarker]] display configuration used when creating a new [[HyperModelingDecorator]]. */\n readonly markers?: SectionMarkerConfig;\n /** Global section graphics configuration used by all [[HyperModelingDecorator]]s when displaying drawings and sheets in a spatial view. Primarily for debugging. */\n readonly graphics?: SectionGraphicsConfig;\n}\n"]}
@@ -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;IAChE,OAAO,IAAI,gBAAgB,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,qBAAqB;IAMzB,YAAmB,MAAqB,EAAE,SAAiC;QACzE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;Q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AI,EAAE,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;IAEO,IAAI;QACV,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,aAAa,CAAC,aAAa,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC,sBAAsB,EAAE,EAAE,CAAC;YAC9F,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YACzB,IAAI,CAAC,QAAQ,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IAEO,eAAe,CAAC,MAAqB;QAC3C,IAAI,SAAS,KAAK,IAAI,CAAC,YAAY;YACjC,OAAO,MAAM,KAAK,IAAI,CAAC,YAAY,CAAC;QAEtC,OAAO,aAAa,CAAC,aAAa,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,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":["/*---------------------------------------------------------------------------------------------\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 { Transform, XAndY } from \"@itwin/core-geometry\";\r\nimport type { AbstractToolbarProps } from \"@itwin/appui-abstract\";\r\nimport {\r\n ChangeFlags, DecorateContext, Decorator, IModelApp, IModelConnection, ScreenViewport, SpatialViewState, TiledGraphicsProvider, ViewClipTool,\r\n} from \"@itwin/core-frontend\";\r\nimport { SectionMarker, SectionMarkerSet } from \"./SectionMarkers\";\r\nimport { SectionDrawingLocationState } from \"./SectionDrawingLocationState\";\r\nimport { createSectionGraphicsProvider } from \"./SectionGraphicsProvider\";\r\nimport { PopupToolbarManager, PopupToolbarProvider } from \"./PopupToolbar\";\r\nimport { HyperModeling } from \"./HyperModeling\";\r\nimport { SectionMarkerConfig } from \"./HyperModelingConfig\";\r\n\r\nasync function createMarkers(vp: ScreenViewport): Promise<SectionMarkerSet | undefined> {\r\n if (!vp.view.isSpatialView())\r\n return undefined;\r\n\r\n const states = await SectionDrawingLocationState.queryAll(vp.iModel);\r\n if (0 === states.length)\r\n return undefined;\r\n\r\n const markers = states.map((state) => new SectionMarker(state));\r\n return new SectionMarkerSet(vp, markers);\r\n}\r\n\r\nclass MarkerToolbarProvider implements PopupToolbarProvider {\r\n private readonly _viewport: ScreenViewport;\r\n public readonly marker: SectionMarker;\r\n public readonly toolbarProps: AbstractToolbarProps;\r\n public readonly onToolbarItemExecuted: (id: string) => void;\r\n\r\n public constructor(marker: SectionMarker, decorator: HyperModelingDecorator) {\r\n this.marker = marker;\r\n this._viewport = decorator.viewport;\r\n this.toolbarProps = HyperModeling.markerHandler.getToolbarProps(marker, decorator);\r\n this.onToolbarItemExecuted = (id) => HyperModeling.markerHandler.executeCommand(id, marker, decorator); // eslint-disable-line @typescript-eslint/promise-function-async\r\n }\r\n\r\n public get overToolbarHotspot() {\r\n return this.marker.isHilited;\r\n }\r\n\r\n public get toolbarLocation(): XAndY {\r\n return { x: this.marker.rect.right, y: this.marker.rect.top };\r\n }\r\n\r\n public get htmlElement() {\r\n return this._viewport.canvas;\r\n }\r\n}\r\n\r\n/** A [Decorator]($frontend) that displays a [[SectionMarker]] for each [SectionDrawingLocation]($backend) in the view.\r\n * Clicking on a marker toggles the section and the display of associated 2d graphics.\r\n * Hovering over a marker opens a mini toolbar with additional interactions.\r\n * @see [[SectionMarkerHandler]] to customize the marker interactions.\r\n * @see [[HyperModeling.startOrStop]] to enable or disable the decorator for a viewport.\r\n * @public\r\n */\r\nexport class HyperModelingDecorator implements Decorator {\r\n /** The set of [[SectionMarker]]s controlled by this decorator. */\r\n public readonly markers: SectionMarkerSet;\r\n private _config: SectionMarkerConfig;\r\n private readonly _removeEventListeners = new Array<() => void>();\r\n private readonly _iModel: IModelConnection;\r\n private _needSync = false;\r\n private _toolbarProvider?: MarkerToolbarProvider;\r\n private _tiledGraphicsProvider?: TiledGraphicsProvider;\r\n private _activeMarker?: SectionMarker;\r\n private _appliedSpatialView?: SpatialViewState;\r\n /** @internal */\r\n public syncImmediately = false;\r\n\r\n /** Create a new decorator and register it with the [ViewManager]($frontend). Typically invoked indirectly via [[HyperModeling.startOrStop]]. */\r\n public static async create(vp: ScreenViewport, config: SectionMarkerConfig): Promise<HyperModelingDecorator | undefined> {\r\n const markers = await createMarkers(vp);\r\n return undefined !== markers ? new HyperModelingDecorator(markers, config) : undefined;\r\n }\r\n\r\n /** Obtain the decorator associated with the specified viewport, if any. */\r\n public static getForViewport(vp: ScreenViewport): HyperModelingDecorator | undefined {\r\n for (const decorator of IModelApp.viewManager.decorators)\r\n if (decorator instanceof HyperModelingDecorator && decorator.viewport === vp)\r\n return decorator;\r\n\r\n return undefined;\r\n }\r\n\r\n /** The viewport into which this decorator draws its [[SectionMarker]]s. */\r\n public get viewport(): ScreenViewport {\r\n return this.markers.viewport;\r\n }\r\n\r\n /** The currently active marker. A marker typically becomes active when the user clicks on it.\r\n * @see [[setActiveMarker]] to change the active marker without user interaction.\r\n */\r\n public get activeMarker(): SectionMarker | undefined {\r\n return this._activeMarker;\r\n }\r\n\r\n /** @internal */\r\n public get config(): SectionMarkerConfig {\r\n return this._config;\r\n }\r\n\r\n /** Replaces the current marker display configuration, overwriting all previous settings. Passing `undefined` resets all settings to defaults.\r\n * @see [[updateConfiguration]] to override specific aspects of the configuration\r\n * @see [[HyperModeling.replaceConfiguration]] to replace the global configuration.\r\n */\r\n public replaceConfiguration(config?: SectionMarkerConfig): void {\r\n this._config = config ? { ...config } : {};\r\n this.requestSync();\r\n }\r\n\r\n /** Overrides specific aspects of the current marker display configuration.\r\n * Any field that is not `undefined` will be replaced in the current configuration; the rest will retain their current values.\r\n * @see [[replaceConfiguration]] to override all settings.\r\n * @see [[HyperModeling.updateConfiguration]] to update the global configuration.\r\n */\r\n public updateConfiguration(config: SectionMarkerConfig): void {\r\n this._config = {\r\n ignoreModelSelector: config.ignoreModelSelector ?? this._config.ignoreModelSelector,\r\n ignoreCategorySelector: config.ignoreCategorySelector ?? this._config.ignoreCategorySelector,\r\n hiddenSectionTypes: config.hiddenSectionTypes ?? this._config.hiddenSectionTypes,\r\n };\r\n\r\n this.requestSync();\r\n }\r\n\r\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.\r\n * Changing the active marker first deactivates the currently active marker, if any; then activates the specified marker, if supplied.\r\n * Returns false if marker activation fails.\r\n * @see [[activeMarker]] to obtain the currently active section marker.\r\n * @see [[SectionMarkerHandler.activateMarker]] to control what happens when a marker is activated.\r\n * @see [[SectionMarkerHandler.deactivateMarker]] to control what happens when a marker is deactivated.\r\n */\r\n public async setActiveMarker(marker: SectionMarker | undefined): Promise<boolean> {\r\n if (marker === this.activeMarker)\r\n return true;\r\n\r\n if (this.activeMarker) {\r\n this.activeMarker.setActive(false);\r\n await HyperModeling.markerHandler.deactivateMarker(this.activeMarker, this);\r\n this._activeMarker = undefined;\r\n }\r\n\r\n if (marker) {\r\n if (!await HyperModeling.markerHandler.activateMarker(marker, this)) {\r\n this.requestSync();\r\n return false;\r\n }\r\n\r\n marker.setActive(true);\r\n this._activeMarker = marker;\r\n }\r\n\r\n this.requestSync();\r\n return true;\r\n }\r\n\r\n /** @internal */\r\n public readonly useCachedDecorations = true;\r\n\r\n /** @internal */\r\n public decorate(context: DecorateContext): void {\r\n if (this.viewport.view.is3d())\r\n this.markers.addDecoration(context);\r\n }\r\n\r\n private constructor(markers: SectionMarkerSet, config: SectionMarkerConfig) {\r\n this.markers = markers;\r\n this._config = { ...config };\r\n this._iModel = this.viewport.iModel;\r\n\r\n this.viewport.onChangeView.addOnce(() => {\r\n this.requestSync();\r\n });\r\n\r\n this._removeEventListeners.push(this.viewport.onViewportChanged.addListener((_, changeFlags) => this.onViewportChanged(changeFlags)));\r\n this._removeEventListeners.push(this.viewport.onDisposed.addListener(() => this.dispose()));\r\n\r\n for (const marker of markers.markers) {\r\n marker.onMouseEnterEvent.addListener((mkr) => this.showToolbarAfterTimeout(mkr));\r\n marker.onMouseButtonEvent.addListener((mkr) => this.toggleMarker(mkr)); // eslint-disable-line @typescript-eslint/promise-function-async\r\n }\r\n\r\n this.updateMarkerVisibility();\r\n IModelApp.viewManager.addDecorator(this);\r\n }\r\n\r\n private onViewportChanged(changeFlags: ChangeFlags): void {\r\n if (this.viewport.iModel !== this._iModel) {\r\n this.dispose();\r\n return;\r\n }\r\n\r\n if (changeFlags.viewedCategories || changeFlags.viewedModels || changeFlags.viewedCategoriesPerModel)\r\n this.requestSync();\r\n\r\n if (changeFlags.viewState) {\r\n // If we're looking at a different view now, and we did not initiate that, turn off the active marker.\r\n if (this.viewport.view !== this._appliedSpatialView)\r\n this.setActiveMarker(undefined); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n else\r\n this._appliedSpatialView = undefined;\r\n }\r\n }\r\n\r\n private async toggleMarker(marker: SectionMarker): Promise<void> {\r\n await this.setActiveMarker(marker === this.activeMarker ? undefined : marker);\r\n }\r\n\r\n private dropTiledGraphicsProvider(): void {\r\n if (undefined === this._tiledGraphicsProvider)\r\n return;\r\n\r\n this.viewport.dropTiledGraphicsProvider(this._tiledGraphicsProvider);\r\n this._tiledGraphicsProvider = undefined;\r\n }\r\n\r\n /** @internal */\r\n public dispose(): void {\r\n if (!IModelApp.viewManager.dropDecorator(this))\r\n return;\r\n\r\n for (const remove of this._removeEventListeners)\r\n remove();\r\n\r\n this.dropTiledGraphicsProvider();\r\n }\r\n\r\n private showToolbarAfterTimeout(marker: SectionMarker): void {\r\n if (this._toolbarProvider?.marker !== marker)\r\n this._toolbarProvider = new MarkerToolbarProvider(marker, this);\r\n\r\n PopupToolbarManager.showToolbarAfterTimeout(this._toolbarProvider);\r\n }\r\n\r\n /** Toggles whether the clip volume associated with the specified marker is applied to the view. */\r\n public toggleClipVolume(marker: SectionMarker, enable: boolean): void {\r\n ViewClipTool.enableClipVolume(this.viewport);\r\n ViewClipTool.setViewClip(this.viewport, enable ? marker.state.clip : undefined);\r\n }\r\n\r\n /** Toggles the specified section marker.\r\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.\r\n * Disabling the section disables the clip volume and 2d graphics.\r\n * @see [[toggleClipVolume]] to toggle only the clip volume.\r\n * @see [[toggleAttachment]] to toggle only the attachment graphics.\r\n */\r\n public async toggleSection(marker: SectionMarker, enable: boolean): Promise<boolean> {\r\n if (enable) {\r\n if (this.viewport.view.is3d()) {\r\n // Preserve the view settings; apply only the frustum and clip volume\r\n const spatialView = await marker.state.tryLoadSpatialView();\r\n if (!spatialView)\r\n return false;\r\n\r\n const aligned = await this.alignToSpatialView(marker);\r\n if (!aligned)\r\n return false;\r\n\r\n this.toggleClipVolume(marker, true);\r\n } else if (!await this.applySpatialView(marker)) {\r\n return false;\r\n }\r\n } else {\r\n this.toggleClipVolume(marker, false);\r\n }\r\n\r\n this.requestSync();\r\n return this.toggleAttachment(marker, enable);\r\n }\r\n\r\n /** Toggles display of 2d section graphics and sheet annotations for the specified marker.\r\n * @see [[toggleSection]] to apply the spatial view and clip volume in addition to the attachment graphics.\r\n */\r\n public async toggleAttachment(marker: SectionMarker, enable: boolean): Promise<boolean> {\r\n this.dropTiledGraphicsProvider();\r\n if (enable) {\r\n this._tiledGraphicsProvider = await createSectionGraphicsProvider(marker.state);\r\n this.viewport.addTiledGraphicsProvider(this._tiledGraphicsProvider);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /** Aligns the viewport to face the specified marker's section plane. */\r\n public alignView(marker: SectionMarker): void {\r\n const placement = marker.state.placement.transform;\r\n const origin = placement.origin;\r\n const matrix = placement.matrix;\r\n\r\n const vp = this.viewport;\r\n const targetMatrix = matrix.multiplyMatrixMatrix(vp.rotation);\r\n const rotateTransform = Transform.createFixedPointAndMatrix(origin, targetMatrix);\r\n\r\n const startFrustum = vp.getFrustum();\r\n const newFrustum = startFrustum.clone();\r\n newFrustum.multiply(rotateTransform);\r\n\r\n if (startFrustum.equals(newFrustum))\r\n return;\r\n\r\n vp.view.setupFromFrustum(newFrustum);\r\n vp.synchWithView();\r\n vp.animateFrustumChange();\r\n }\r\n\r\n /** Opens the marker's drawing view in the decorator's viewport. Returns false if the drawing view could not be loaded. */\r\n public async openSection(marker: SectionMarker): Promise<boolean> {\r\n const viewState = await marker.state.tryLoadDrawingView();\r\n if (viewState)\r\n this.viewport.changeView(viewState);\r\n\r\n return undefined !== viewState;\r\n }\r\n\r\n /** Opens marker's sheet view in the decorator's viewport and zooms in on the associated [ViewAttachment]($backend). Returns false if no view\r\n * attachment exists or the sheet view could not be loaded.\r\n */\r\n public async openSheet(marker: SectionMarker): Promise<boolean> {\r\n if (undefined === marker.state.viewAttachment)\r\n return false;\r\n\r\n const viewState = await marker.state.tryLoadSheetView();\r\n if (!viewState)\r\n return false;\r\n\r\n this.viewport.changeView(viewState);\r\n await this.viewport.zoomToElements(marker.state.viewAttachment.id);\r\n return true;\r\n }\r\n\r\n /** Aligns the view to match the frustum of the spatial view associated with the specified marker.\r\n * @param marker The marker whose spatial view's frustum should be applied.\r\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.\r\n * @see [[alignView]] to align to the *section plane*, which may differ.\r\n * @see [[toggleSection]] to also apply the clip volume.\r\n */\r\n public async alignToSpatialView(marker: SectionMarker): Promise<boolean> {\r\n if (!this.viewport.view.is3d())\r\n return false;\r\n\r\n const spatialView = await marker.state.tryLoadSpatialView();\r\n if (!spatialView)\r\n return false;\r\n\r\n this.viewport.view.setOrigin(spatialView.getOrigin());\r\n this.viewport.view.setExtents(spatialView.getExtents());\r\n this.viewport.view.setRotation(spatialView.getRotation());\r\n this.viewport.synchWithView({ animateFrustumChange: true });\r\n\r\n return true;\r\n }\r\n\r\n /** Applies the marker's spatial view - including its clip volume - to the decorator's viewport.\r\n * Returns false if the spatial view could not be loaded.\r\n * @see [[toggleSection]].\r\n * @see [[toggleClipVolume]].\r\n */\r\n public async applySpatialView(marker: SectionMarker): Promise<boolean> {\r\n const viewState = await marker.state.tryLoadSpatialView();\r\n if (viewState) {\r\n this._appliedSpatialView = viewState;\r\n this.viewport.changeView(viewState);\r\n }\r\n\r\n return undefined !== viewState;\r\n }\r\n\r\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\r\n * this method when the criteria governing your `isMarkerVisible` method have changed.\r\n */\r\n public requestSync(): void {\r\n if (this.syncImmediately) {\r\n this.sync();\r\n } else if (!this._needSync) {\r\n this._needSync = true;\r\n requestAnimationFrame(() => this.sync());\r\n }\r\n }\r\n\r\n private sync(): void {\r\n this._needSync = false;\r\n if (HyperModeling.isInitialized && this.viewport.view.is3d() && this.updateMarkerVisibility()) {\r\n this.markers.markDirty();\r\n this.viewport.invalidateCachedDecorations(this);\r\n }\r\n }\r\n\r\n private isMarkerVisible(marker: SectionMarker): boolean {\r\n if (undefined !== this.activeMarker)\r\n return marker === this.activeMarker;\r\n\r\n return HyperModeling.markerHandler.isMarkerVisible(marker, this, this._config);\r\n }\r\n\r\n private updateMarkerVisibility(): boolean {\r\n let changed = false;\r\n for (const marker of this.markers.markers) {\r\n const wasVisible = marker.visible;\r\n marker.visible = this.isMarkerVisible(marker);\r\n changed = changed || (marker.visible !== wasVisible);\r\n }\r\n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C,aAAa,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC,sBAAsB,EAAE,EAAE,CAAC;YAC9F,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YACzB,IAAI,CAAC,QAAQ,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IAEO,eAAe,CAAC,MAAqB;QAC3C,IAAI,SAAS,KAAK,IAAI,CAAC,YAAY;YACjC,OAAO,MAAM,KAAK,IAAI,CAAC,YAAY,CAAC;QAEtC,OAAO,aAAa,CAAC,aAAa,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,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.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.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 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 +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;IAItB,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,CAAC;QAChC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC;YAC5I,OAAO,KAAK,CAAC;QAEf,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAgBO,MAAM,CAAC,KAAK;QAClB,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC1B,OAAO,SAAS,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;IACzC,CAAC;IAEO,MAAM,CAAC,iBAAiB;QAC9B,IAAI,CAAC,IAAI,CAAC,QAAQ;YAChB,OAAO;QAET,MAAM,KAAK,GAAG,IAAI,CAAC;QACnB,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,IAAI,CAAC,SAAS,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;;AApCc,iCAAa,GAAG,CAAC,IAAS,EAAE,EAAE;IAC3C,MAAM,GAAG,GAAG,mBAAmB,CAAC;IAChC,IAAI,GAAG,CAAC,QAAQ;QACd,GAAG,CAAC,QAAQ,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAE9C,GAAG,CAAC,KAAK,EAAE,CAAC;AACd,CAAC,CAAC;AAEa,2BAAO,GAAG,GAAG,EAAE;IAC5B,MAAM,GAAG,GAAG,mBAAmB,CAAC;IAChC,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,kBAAkB;QACnD,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,wCAAwC;AACzD,CAAC,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 { XAndY } from \"@itwin/core-geometry\";\r\nimport type { AbstractToolbarProps } from \"@itwin/appui-abstract\";\r\nimport { IModelApp } from \"@itwin/core-frontend\";\r\n\r\n/** @internal */\r\nexport interface PopupToolbarProvider {\r\n toolbarProps: AbstractToolbarProps;\r\n overToolbarHotspot: boolean;\r\n toolbarLocation: XAndY;\r\n htmlElement: HTMLElement | undefined;\r\n onToolbarItemExecuted(id: string): void;\r\n}\r\n\r\n/** @internal */\r\nexport class PopupToolbarManager {\r\n private static _provider?: PopupToolbarProvider;\r\n private static _current?: PopupToolbarProvider;\r\n\r\n private static show(): boolean {\r\n const prov = this._provider;\r\n if (!prov || !prov.overToolbarHotspot)\r\n return false;\r\n\r\n const admin = IModelApp.uiAdmin;\r\n if (!admin.showToolbar(prov.toolbarProps, prov.toolbarLocation, { x: 0, y: 0 }, this._itemExecuted, this._cancel, undefined, prov.htmlElement))\r\n return false;\r\n\r\n this._current = this._provider;\r\n this._provider = undefined;\r\n this.closeAfterTimeout();\r\n return true;\r\n }\r\n\r\n private static _itemExecuted = (item: any) => {\r\n const mgr = PopupToolbarManager;\r\n if (mgr._current)\r\n mgr._current.onToolbarItemExecuted(item.id);\r\n\r\n mgr.close();\r\n };\r\n\r\n private static _cancel = () => {\r\n const mgr = PopupToolbarManager;\r\n if (!mgr._current || !mgr._current.overToolbarHotspot)\r\n mgr.close(); // Don't hide when click is over hotspot\r\n };\r\n\r\n private static close(): boolean {\r\n this._current = undefined;\r\n return IModelApp.uiAdmin.hideToolbar();\r\n }\r\n\r\n private static closeAfterTimeout(): void {\r\n if (!this._current)\r\n return;\r\n\r\n const delay = 1000;\r\n if (this._current.overToolbarHotspot || !IModelApp.toolAdmin.cursorView)\r\n setTimeout(() => this.closeAfterTimeout(), delay); // Cursor not in view or over hotspot, check again\r\n else\r\n this.close();\r\n }\r\n\r\n public static showToolbarAfterTimeout(provider: PopupToolbarProvider): void {\r\n if (this._current === provider)\r\n return;\r\n\r\n this._provider = provider;\r\n setTimeout(() => this.show(), 500);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"PopupToolbar.js","sourceRoot":"","sources":["../../src/PopupToolbar.ts"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AK,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;;AApCc,iCAAa,GAAG,CAAC,IAAS,EAAE,EAAE;IAC3C,MAAM,GAAG,GAAG,mBAAmB,CAAC;IAChC,IAAI,GAAG,CAAC,QAAQ;QACd,GAAG,CAAC,QAAQ,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAE9C,GAAG,CAAC,KAAK,EAAE,CAAC;AACd,CAAC,CAAC;AAEa,2BAAO,GAAG,GAAG,EAAE;IAC5B,MAAM,GAAG,GAAG,mBAAmB,CAAC;IAChC,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,kBAAkB;QACnD,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,wCAAwC;AACzD,CAAC,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"]}
@@ -8,35 +8,35 @@
8
8
  import { Placement3d, QueryRowFormat } from "@itwin/core-common";
9
9
  import { DrawingViewState, SheetViewState, SpatialViewState } from "@itwin/core-frontend";
10
10
  import { ClipVector, Transform } from "@itwin/core-geometry";
11
- const selectSectionDrawingLocationStatesECSql = `
12
- SELECT
13
- bis.SectionDrawingLocation.ECInstanceId as sectionLocationId,
14
- bis.SectionDrawingLocation.Model.Id as sectionLocationModelId,
15
- bis.SectionDrawingLocation.SectionView.Id as sectionViewId,
16
- bis.SectionDrawingLocation.Category.Id as categoryId,
17
- bis.SectionDrawingLocation.Origin as origin,
18
- bis.SectionDrawingLocation.Yaw as yaw,
19
- bis.SectionDrawingLocation.Pitch as pitch,
20
- bis.SectionDrawingLocation.Roll as roll,
21
- bis.SectionDrawingLocation.BBoxLow as bboxLow,
22
- bis.SectionDrawingLocation.BBoxHigh as bboxHigh,
23
- bis.SectionDrawingLocation.UserLabel as userLabel,
24
-
25
- bis.SectionDrawing.SectionType as sectionType,
26
- json_extract(bis.SectionDrawing.jsonProperties, '$.drawingToSpatialTransform') as drawingToSpatialTransform,
27
- bis.SectionDrawing.SpatialView.Id as spatialViewId,
28
- json_extract(bis.SectionDrawing.jsonProperties, '$.sheetToSpatialTransform') as sheetToSpatialTransform,
29
- json_extract(bis.SectionDrawing.jsonProperties, '$.drawingBoundaryClip') as sheetClip,
30
-
31
- json_extract(bis.SpatialViewDefinition.jsonProperties, '$.viewDetails.clip') as clipJSON,
32
- bis.ViewAttachment.ECInstanceId as viewAttachmentId,
33
- bis.SheetViewDefinition.ECInstanceId as sheetViewId
34
- FROM bis.SectionDrawingLocation
35
- INNER JOIN bis.ViewDefinition2d on bis.SectionDrawingLocation.SectionView.Id = bis.ViewDefinition2d.ECInstanceId
36
- INNER JOIN bis.SectionDrawing on bis.ViewDefinition2d.BaseModel.Id = bis.SectionDrawing.ECInstanceId
37
- LEFT JOIN bis.ViewAttachment on bis.ViewDefinition2d.ECInstanceId = bis.ViewAttachment.View.Id
38
- LEFT JOIN bis.SheetViewDefinition on bis.SheetViewDefinition.BaseModel.Id = bis.ViewAttachment.Model.Id
39
- INNER JOIN bis.SpatialViewDefinition on bis.SpatialViewDefinition.ECInstanceId = bis.SectionDrawing.SpatialView.Id
11
+ const selectSectionDrawingLocationStatesECSql = `
12
+ SELECT
13
+ bis.SectionDrawingLocation.ECInstanceId as sectionLocationId,
14
+ bis.SectionDrawingLocation.Model.Id as sectionLocationModelId,
15
+ bis.SectionDrawingLocation.SectionView.Id as sectionViewId,
16
+ bis.SectionDrawingLocation.Category.Id as categoryId,
17
+ bis.SectionDrawingLocation.Origin as origin,
18
+ bis.SectionDrawingLocation.Yaw as yaw,
19
+ bis.SectionDrawingLocation.Pitch as pitch,
20
+ bis.SectionDrawingLocation.Roll as roll,
21
+ bis.SectionDrawingLocation.BBoxLow as bboxLow,
22
+ bis.SectionDrawingLocation.BBoxHigh as bboxHigh,
23
+ bis.SectionDrawingLocation.UserLabel as userLabel,
24
+
25
+ bis.SectionDrawing.SectionType as sectionType,
26
+ json_extract(bis.SectionDrawing.jsonProperties, '$.drawingToSpatialTransform') as drawingToSpatialTransform,
27
+ bis.SectionDrawing.SpatialView.Id as spatialViewId,
28
+ json_extract(bis.SectionDrawing.jsonProperties, '$.sheetToSpatialTransform') as sheetToSpatialTransform,
29
+ json_extract(bis.SectionDrawing.jsonProperties, '$.drawingBoundaryClip') as sheetClip,
30
+
31
+ json_extract(bis.SpatialViewDefinition.jsonProperties, '$.viewDetails.clip') as clipJSON,
32
+ bis.ViewAttachment.ECInstanceId as viewAttachmentId,
33
+ bis.SheetViewDefinition.ECInstanceId as sheetViewId
34
+ FROM bis.SectionDrawingLocation
35
+ INNER JOIN bis.ViewDefinition2d on bis.SectionDrawingLocation.SectionView.Id = bis.ViewDefinition2d.ECInstanceId
36
+ INNER JOIN bis.SectionDrawing on bis.ViewDefinition2d.BaseModel.Id = bis.SectionDrawing.ECInstanceId
37
+ LEFT JOIN bis.ViewAttachment on bis.ViewDefinition2d.ECInstanceId = bis.ViewAttachment.View.Id
38
+ LEFT JOIN bis.SheetViewDefinition on bis.SheetViewDefinition.BaseModel.Id = bis.ViewAttachment.Model.Id
39
+ INNER JOIN bis.SpatialViewDefinition on bis.SpatialViewDefinition.ECInstanceId = bis.SectionDrawing.SpatialView.Id
40
40
  `;
41
41
  /** Represents a [SectionDrawingLocation]($backend), including data from related elements like [SectionDrawing]($backend) used in a hyper-modeling context.
42
42
  * @see [[SectionMarker]] for a widget that allows the user to interact with a section drawing location.
@@ -1 +1 @@
1
- {"version":3,"file":"SectionDrawingLocationState.js","sourceRoot":"","sources":["../../src/SectionDrawingLocationState.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAA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esContent":["/*---------------------------------------------------------------------------------------------\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 { Id64String } from \"@itwin/core-bentley\";\r\nimport { Placement3d, QueryRowFormat, SectionType } from \"@itwin/core-common\";\r\nimport { DrawingViewState, IModelConnection, SheetViewState, SpatialViewState } from \"@itwin/core-frontend\";\r\nimport { ClipVector, Transform, XYZProps } from \"@itwin/core-geometry\";\r\n\r\nconst selectSectionDrawingLocationStatesECSql = `\r\n SELECT\r\n bis.SectionDrawingLocation.ECInstanceId as sectionLocationId,\r\n bis.SectionDrawingLocation.Model.Id as sectionLocationModelId,\r\n bis.SectionDrawingLocation.SectionView.Id as sectionViewId,\r\n bis.SectionDrawingLocation.Category.Id as categoryId,\r\n bis.SectionDrawingLocation.Origin as origin,\r\n bis.SectionDrawingLocation.Yaw as yaw,\r\n bis.SectionDrawingLocation.Pitch as pitch,\r\n bis.SectionDrawingLocation.Roll as roll,\r\n bis.SectionDrawingLocation.BBoxLow as bboxLow,\r\n bis.SectionDrawingLocation.BBoxHigh as bboxHigh,\r\n bis.SectionDrawingLocation.UserLabel as userLabel,\r\n\r\n bis.SectionDrawing.SectionType as sectionType,\r\n json_extract(bis.SectionDrawing.jsonProperties, '$.drawingToSpatialTransform') as drawingToSpatialTransform,\r\n bis.SectionDrawing.SpatialView.Id as spatialViewId,\r\n json_extract(bis.SectionDrawing.jsonProperties, '$.sheetToSpatialTransform') as sheetToSpatialTransform,\r\n json_extract(bis.SectionDrawing.jsonProperties, '$.drawingBoundaryClip') as sheetClip,\r\n\r\n json_extract(bis.SpatialViewDefinition.jsonProperties, '$.viewDetails.clip') as clipJSON,\r\n bis.ViewAttachment.ECInstanceId as viewAttachmentId,\r\n bis.SheetViewDefinition.ECInstanceId as sheetViewId\r\n FROM bis.SectionDrawingLocation\r\n INNER JOIN bis.ViewDefinition2d on bis.SectionDrawingLocation.SectionView.Id = bis.ViewDefinition2d.ECInstanceId\r\n INNER JOIN bis.SectionDrawing on bis.ViewDefinition2d.BaseModel.Id = bis.SectionDrawing.ECInstanceId\r\n LEFT JOIN bis.ViewAttachment on bis.ViewDefinition2d.ECInstanceId = bis.ViewAttachment.View.Id\r\n LEFT JOIN bis.SheetViewDefinition on bis.SheetViewDefinition.BaseModel.Id = bis.ViewAttachment.Model.Id\r\n INNER JOIN bis.SpatialViewDefinition on bis.SpatialViewDefinition.ECInstanceId = bis.SectionDrawing.SpatialView.Id\r\n`;\r\n\r\n/** Raw data representing a [[SectionDrawingLocationState]]. This is an amalgamation of data from several related ECClasses.\r\n * @internal\r\n */\r\nexport interface SectionDrawingLocationStateData {\r\n sectionType: SectionType;\r\n drawingToSpatialTransform: string; // stringified TransformProps\r\n spatialViewId: Id64String;\r\n clipJSON?: string; // stringified ClipVector json\r\n viewAttachmentId?: Id64String;\r\n sheetToSpatialTransform?: string; // stringified TransformProps\r\n sheetClip?: string; // stringified ClipVector json\r\n sheetViewId?: Id64String;\r\n\r\n sectionLocationId: Id64String;\r\n sectionLocationModelId: Id64String;\r\n sectionViewId: Id64String;\r\n categoryId: Id64String;\r\n origin?: XYZProps;\r\n yaw?: number;\r\n pitch?: number;\r\n roll?: number;\r\n bboxLow?: XYZProps;\r\n bboxHigh?: XYZProps;\r\n userLabel: string;\r\n}\r\n\r\n/** Represents a [ViewAttachment]($backend) that attaches a [[SectionDrawingLocationState]] to a [Sheet]($backend) model.\r\n * @public\r\n */\r\nexport interface SectionViewAttachment {\r\n /** The view attachment's element Id. */\r\n readonly id: Id64String;\r\n /** The Id of a [SheetViewDefinition]($backend) that displays this view attachment.\r\n * This is used when navigating from the spatial view to the view attachment.\r\n */\r\n readonly viewId?: Id64String;\r\n /** The transform from the [Sheet]($backend) coordinate space to the spatial coordinate space. */\r\n readonly transformToSpatial: Transform;\r\n /** Optional 2d clip vector used to clip out portions of the [Sheet]($backend) containing annotations not relevant to this section drawing. */\r\n readonly clip?: ClipVector;\r\n}\r\n\r\n/** Represents a [SectionDrawingLocation]($backend), including data from related elements like [SectionDrawing]($backend) used in a hyper-modeling context.\r\n * @see [[SectionMarker]] for a widget that allows the user to interact with a section drawing location.\r\n * @public\r\n */\r\nexport class SectionDrawingLocationState {\r\n /** The iModel in which this section drawing location resides. */\r\n public readonly iModel: IModelConnection;\r\n /** The element Id of the section drawing location. */\r\n public readonly id: Id64String;\r\n /** The Id of the [GeometricModel3d]($backend) in which this section drawing location resides. */\r\n public readonly model: Id64String;\r\n /** A user-friendly label for the section drawing location. */\r\n public readonly userLabel: string;\r\n /** The Id of the [SpatialCategory]($backend) to which this section drawing location belongs. */\r\n public readonly category: Id64String;\r\n /** The section drawing location's spatial placement. */\r\n public readonly placement: Placement3d;\r\n /** The type of section that generated the associated [SectionDrawing]($backend). */\r\n public readonly sectionType: SectionType;\r\n /** The Id of the [ViewDefinition]($backend) that can display the section graphics. */\r\n public readonly drawingViewId: Id64String;\r\n /** The Id of the [SpatialViewDefinition]($backend) from which the section drawing was generated. */\r\n public readonly spatialViewId: Id64String;\r\n /** The section clip from the [SpatialViewDefinition]($backend) from which the section drawing was generated. */\r\n public readonly clip: ClipVector;\r\n /** The transform from the [GeometricModel]($backend) containing the section graphics to the spatial coordinate space.\r\n * This is used to position the 2d graphics in the context of a spatial view.\r\n */\r\n public readonly drawingToSpatialTransform: Transform;\r\n /** If the section drawing is attached to a [Sheet]($backend), details about the corresponding [ViewAttachment]($backend).\r\n * When this section drawing location is displayed in a spatial context, annotations in the sheet model can be displayed along with the section graphics.\r\n */\r\n public readonly viewAttachment?: SectionViewAttachment;\r\n\r\n /** @internal */\r\n public constructor(props: SectionDrawingLocationStateData, iModel: IModelConnection) {\r\n this.iModel = iModel;\r\n this.id = props.sectionLocationId;\r\n this.model = props.sectionLocationModelId;\r\n this.userLabel = props.userLabel;\r\n this.category = props.categoryId;\r\n this.sectionType = props.sectionType;\r\n this.drawingViewId = props.sectionViewId;\r\n this.spatialViewId = props.spatialViewId;\r\n this.drawingToSpatialTransform = Transform.fromJSON(JSON.parse(props.drawingToSpatialTransform));\r\n\r\n const extractClip = (str: string | undefined) => {\r\n let clip;\r\n if (str) {\r\n try {\r\n clip = ClipVector.fromJSON(JSON.parse(str));\r\n } catch { }\r\n }\r\n\r\n return clip;\r\n };\r\n\r\n this.clip = extractClip(props.clipJSON) ?? ClipVector.createEmpty();\r\n\r\n const placementProps = {\r\n origin: props.origin ?? {},\r\n angles: {\r\n yaw: props.yaw,\r\n pitch: props.pitch,\r\n roll: props.roll,\r\n },\r\n placement: (props.bboxLow && props.bboxHigh) ? { low: props.bboxLow, high: props.bboxHigh } : undefined,\r\n };\r\n this.placement = Placement3d.fromJSON(placementProps);\r\n\r\n if (props.viewAttachmentId && props.sheetToSpatialTransform) {\r\n this.viewAttachment = {\r\n id: props.viewAttachmentId,\r\n transformToSpatial: Transform.fromJSON(JSON.parse(props.sheetToSpatialTransform)),\r\n clip: extractClip(props.sheetClip),\r\n viewId: props.sheetViewId,\r\n };\r\n }\r\n }\r\n\r\n /** Return a promise that resolves to the [DrawingViewState]($frontend) corresponding to `this.drawingViewId`, or undefined if an exception occurs. */\r\n public async tryLoadDrawingView(): Promise<DrawingViewState | undefined> {\r\n try {\r\n const view = await this.iModel.views.load(this.drawingViewId);\r\n if (view instanceof DrawingViewState)\r\n return view;\r\n } catch { }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Return a promise that resolves to the [SpatialViewState]($frontend) corresponding to `this.spatialViewId`, or undefined if an exception occurs. */\r\n public async tryLoadSpatialView(): Promise<SpatialViewState | undefined> {\r\n try {\r\n const view = await this.iModel.views.load(this.spatialViewId);\r\n if (view instanceof SpatialViewState)\r\n return view;\r\n } catch { }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Return a promise that resolves to the [SheetViewState]($frontend) corresponding to `this.viewAttachment.viewId`; or undefined if there is no corresponding [ViewAttachment]($backend) or an exception occurs. */\r\n public async tryLoadSheetView(): Promise<SheetViewState | undefined> {\r\n if (undefined === this.viewAttachment || undefined === this.viewAttachment.viewId)\r\n return undefined;\r\n\r\n try {\r\n const view = await this.iModel.views.load(this.viewAttachment.viewId);\r\n if (view instanceof SheetViewState)\r\n return view;\r\n } catch { }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Query the specified iModel for [SectionDrawingLocation]($backend)s and return a list of corresponding [[SectionDrawingLocationState]]s. */\r\n public static async queryAll(iModel: IModelConnection): Promise<SectionDrawingLocationState[]> {\r\n const states: SectionDrawingLocationState[] = [];\r\n try {\r\n for await (const row of iModel.createQueryReader(selectSectionDrawingLocationStatesECSql, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }))\r\n states.push(new SectionDrawingLocationState(row.toRow() as SectionDrawingLocationStateData, iModel));\r\n } catch {\r\n // If the iModel contains a version of BisCore schema older than 1.12.0, the query will produce an exception due to missing SectionDrawingLocation class. That's fine.\r\n }\r\n\r\n return states;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SectionDrawingLocationState.js","sourceRoot":"","sources":["../../src/SectionDrawingLocationState.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAe,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAoB,cAAc,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC5G,OAAO,EAAE,UAAU,EAAE,SAAS,EAAY,MAAM,sBAAsB,CAAC;AAEvE,MAAM,uCAAuC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6B/C,CAAC;AA4CF;;;GAGG;AACH,MAAM,OAAO,2BAA2B;IA8BtC,gBAAgB;IAChB,YAAmB,KAAsC,EAAE,MAAwB;QACjF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,iBAAiB,CAAC;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MAAM;YAC/E,OAAO,SAAS,CAAC;QAEnB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YACtE,IAAI,IAAI,YAAY,cAAc;gBAChC,OAAO,IAAI,CAAC;QAChB,CAAC;QAAC,MAAM,CAAC,CAAC,CAAC;QAEX,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,8IAA8I;IACvI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAwB;QACnD,MAAM,MAAM,GAAkC,EAAE,CAAC;QACjD,IAAI,CAAC;YACH,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,MAAM,CAAC,iBAAiB,CAAC,uCAAuC,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,cAAc,CAAC,kBAAkB,EAAE,CAAC;gBACpJ,MAAM,CAAC,IAAI,CAAC,IAAI,2BAA2B,CAAC,GAAG,CAAC,KAAK,EAAqC,EAAE,MAAM,CAAC,CAAC,CAAC;QACzG,CAAC;QAAC,MAAM,CAAC;YACP,sKAAsK;QACxK,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,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 { Id64String } from \"@itwin/core-bentley\";\nimport { Placement3d, QueryRowFormat, SectionType } from \"@itwin/core-common\";\nimport { DrawingViewState, IModelConnection, SheetViewState, SpatialViewState } from \"@itwin/core-frontend\";\nimport { ClipVector, Transform, XYZProps } from \"@itwin/core-geometry\";\n\nconst selectSectionDrawingLocationStatesECSql = `\n SELECT\n bis.SectionDrawingLocation.ECInstanceId as sectionLocationId,\n bis.SectionDrawingLocation.Model.Id as sectionLocationModelId,\n bis.SectionDrawingLocation.SectionView.Id as sectionViewId,\n bis.SectionDrawingLocation.Category.Id as categoryId,\n bis.SectionDrawingLocation.Origin as origin,\n bis.SectionDrawingLocation.Yaw as yaw,\n bis.SectionDrawingLocation.Pitch as pitch,\n bis.SectionDrawingLocation.Roll as roll,\n bis.SectionDrawingLocation.BBoxLow as bboxLow,\n bis.SectionDrawingLocation.BBoxHigh as bboxHigh,\n bis.SectionDrawingLocation.UserLabel as userLabel,\n\n bis.SectionDrawing.SectionType as sectionType,\n json_extract(bis.SectionDrawing.jsonProperties, '$.drawingToSpatialTransform') as drawingToSpatialTransform,\n bis.SectionDrawing.SpatialView.Id as spatialViewId,\n json_extract(bis.SectionDrawing.jsonProperties, '$.sheetToSpatialTransform') as sheetToSpatialTransform,\n json_extract(bis.SectionDrawing.jsonProperties, '$.drawingBoundaryClip') as sheetClip,\n\n json_extract(bis.SpatialViewDefinition.jsonProperties, '$.viewDetails.clip') as clipJSON,\n bis.ViewAttachment.ECInstanceId as viewAttachmentId,\n bis.SheetViewDefinition.ECInstanceId as sheetViewId\n FROM bis.SectionDrawingLocation\n INNER JOIN bis.ViewDefinition2d on bis.SectionDrawingLocation.SectionView.Id = bis.ViewDefinition2d.ECInstanceId\n INNER JOIN bis.SectionDrawing on bis.ViewDefinition2d.BaseModel.Id = bis.SectionDrawing.ECInstanceId\n LEFT JOIN bis.ViewAttachment on bis.ViewDefinition2d.ECInstanceId = bis.ViewAttachment.View.Id\n LEFT JOIN bis.SheetViewDefinition on bis.SheetViewDefinition.BaseModel.Id = bis.ViewAttachment.Model.Id\n INNER JOIN bis.SpatialViewDefinition on bis.SpatialViewDefinition.ECInstanceId = bis.SectionDrawing.SpatialView.Id\n`;\n\n/** Raw data representing a [[SectionDrawingLocationState]]. This is an amalgamation of data from several related ECClasses.\n * @internal\n */\nexport interface SectionDrawingLocationStateData {\n sectionType: SectionType;\n drawingToSpatialTransform: string; // stringified TransformProps\n spatialViewId: Id64String;\n clipJSON?: string; // stringified ClipVector json\n viewAttachmentId?: Id64String;\n sheetToSpatialTransform?: string; // stringified TransformProps\n sheetClip?: string; // stringified ClipVector json\n sheetViewId?: Id64String;\n\n sectionLocationId: Id64String;\n sectionLocationModelId: Id64String;\n sectionViewId: Id64String;\n categoryId: Id64String;\n origin?: XYZProps;\n yaw?: number;\n pitch?: number;\n roll?: number;\n bboxLow?: XYZProps;\n bboxHigh?: XYZProps;\n userLabel: string;\n}\n\n/** Represents a [ViewAttachment]($backend) that attaches a [[SectionDrawingLocationState]] to a [Sheet]($backend) model.\n * @public\n */\nexport interface SectionViewAttachment {\n /** The view attachment's element Id. */\n readonly id: Id64String;\n /** The Id of a [SheetViewDefinition]($backend) that displays this view attachment.\n * This is used when navigating from the spatial view to the view attachment.\n */\n readonly viewId?: Id64String;\n /** The transform from the [Sheet]($backend) coordinate space to the spatial coordinate space. */\n readonly transformToSpatial: Transform;\n /** Optional 2d clip vector used to clip out portions of the [Sheet]($backend) containing annotations not relevant to this section drawing. */\n readonly clip?: ClipVector;\n}\n\n/** Represents a [SectionDrawingLocation]($backend), including data from related elements like [SectionDrawing]($backend) used in a hyper-modeling context.\n * @see [[SectionMarker]] for a widget that allows the user to interact with a section drawing location.\n * @public\n */\nexport class SectionDrawingLocationState {\n /** The iModel in which this section drawing location resides. */\n public readonly iModel: IModelConnection;\n /** The element Id of the section drawing location. */\n public readonly id: Id64String;\n /** The Id of the [GeometricModel3d]($backend) in which this section drawing location resides. */\n public readonly model: Id64String;\n /** A user-friendly label for the section drawing location. */\n public readonly userLabel: string;\n /** The Id of the [SpatialCategory]($backend) to which this section drawing location belongs. */\n public readonly category: Id64String;\n /** The section drawing location's spatial placement. */\n public readonly placement: Placement3d;\n /** The type of section that generated the associated [SectionDrawing]($backend). */\n public readonly sectionType: SectionType;\n /** The Id of the [ViewDefinition]($backend) that can display the section graphics. */\n public readonly drawingViewId: Id64String;\n /** The Id of the [SpatialViewDefinition]($backend) from which the section drawing was generated. */\n public readonly spatialViewId: Id64String;\n /** The section clip from the [SpatialViewDefinition]($backend) from which the section drawing was generated. */\n public readonly clip: ClipVector;\n /** The transform from the [GeometricModel]($backend) containing the section graphics to the spatial coordinate space.\n * This is used to position the 2d graphics in the context of a spatial view.\n */\n public readonly drawingToSpatialTransform: Transform;\n /** If the section drawing is attached to a [Sheet]($backend), details about the corresponding [ViewAttachment]($backend).\n * When this section drawing location is displayed in a spatial context, annotations in the sheet model can be displayed along with the section graphics.\n */\n public readonly viewAttachment?: SectionViewAttachment;\n\n /** @internal */\n public constructor(props: SectionDrawingLocationStateData, iModel: IModelConnection) {\n this.iModel = iModel;\n this.id = props.sectionLocationId;\n this.model = props.sectionLocationModelId;\n this.userLabel = props.userLabel;\n this.category = props.categoryId;\n this.sectionType = props.sectionType;\n this.drawingViewId = props.sectionViewId;\n this.spatialViewId = props.spatialViewId;\n this.drawingToSpatialTransform = Transform.fromJSON(JSON.parse(props.drawingToSpatialTransform));\n\n const extractClip = (str: string | undefined) => {\n let clip;\n if (str) {\n try {\n clip = ClipVector.fromJSON(JSON.parse(str));\n } catch { }\n }\n\n return clip;\n };\n\n this.clip = extractClip(props.clipJSON) ?? ClipVector.createEmpty();\n\n const placementProps = {\n origin: props.origin ?? {},\n angles: {\n yaw: props.yaw,\n pitch: props.pitch,\n roll: props.roll,\n },\n placement: (props.bboxLow && props.bboxHigh) ? { low: props.bboxLow, high: props.bboxHigh } : undefined,\n };\n this.placement = Placement3d.fromJSON(placementProps);\n\n if (props.viewAttachmentId && props.sheetToSpatialTransform) {\n this.viewAttachment = {\n id: props.viewAttachmentId,\n transformToSpatial: Transform.fromJSON(JSON.parse(props.sheetToSpatialTransform)),\n clip: extractClip(props.sheetClip),\n viewId: props.sheetViewId,\n };\n }\n }\n\n /** Return a promise that resolves to the [DrawingViewState]($frontend) corresponding to `this.drawingViewId`, or undefined if an exception occurs. */\n public async tryLoadDrawingView(): Promise<DrawingViewState | undefined> {\n try {\n const view = await this.iModel.views.load(this.drawingViewId);\n if (view instanceof DrawingViewState)\n return view;\n } catch { }\n\n return undefined;\n }\n\n /** Return a promise that resolves to the [SpatialViewState]($frontend) corresponding to `this.spatialViewId`, or undefined if an exception occurs. */\n public async tryLoadSpatialView(): Promise<SpatialViewState | undefined> {\n try {\n const view = await this.iModel.views.load(this.spatialViewId);\n if (view instanceof SpatialViewState)\n return view;\n } catch { }\n\n return undefined;\n }\n\n /** Return a promise that resolves to the [SheetViewState]($frontend) corresponding to `this.viewAttachment.viewId`; or undefined if there is no corresponding [ViewAttachment]($backend) or an exception occurs. */\n public async tryLoadSheetView(): Promise<SheetViewState | undefined> {\n if (undefined === this.viewAttachment || undefined === this.viewAttachment.viewId)\n return undefined;\n\n try {\n const view = await this.iModel.views.load(this.viewAttachment.viewId);\n if (view instanceof SheetViewState)\n return view;\n } catch { }\n\n return undefined;\n }\n\n /** Query the specified iModel for [SectionDrawingLocation]($backend)s and return a list of corresponding [[SectionDrawingLocationState]]s. */\n public static async queryAll(iModel: IModelConnection): Promise<SectionDrawingLocationState[]> {\n const states: SectionDrawingLocationState[] = [];\n try {\n for await (const row of iModel.createQueryReader(selectSectionDrawingLocationStatesECSql, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }))\n states.push(new SectionDrawingLocationState(row.toRow() as SectionDrawingLocationStateData, iModel));\n } catch {\n // If the iModel contains a version of BisCore schema older than 1.12.0, the query will produce an exception due to missing SectionDrawingLocation class. That's fine.\n }\n\n return states;\n }\n}\n"]}