@itwin/hypermodeling-frontend 5.0.0-dev.8 → 5.0.0-dev.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +46 -1
  2. package/lib/cjs/HyperModeling.js +7 -4
  3. package/lib/cjs/HyperModeling.js.map +1 -1
  4. package/lib/cjs/HyperModelingDecorator.d.ts +1 -1
  5. package/lib/cjs/HyperModelingDecorator.d.ts.map +1 -1
  6. package/lib/cjs/HyperModelingDecorator.js +21 -9
  7. package/lib/cjs/HyperModelingDecorator.js.map +1 -1
  8. package/lib/cjs/PopupToolbar.js +13 -11
  9. package/lib/cjs/PopupToolbar.js.map +1 -1
  10. package/lib/cjs/SectionDrawingLocationState.js +28 -0
  11. package/lib/cjs/SectionDrawingLocationState.js.map +1 -1
  12. package/lib/cjs/SectionGraphicsProvider.d.ts.map +1 -1
  13. package/lib/cjs/SectionGraphicsProvider.js +14 -0
  14. package/lib/cjs/SectionGraphicsProvider.js.map +1 -1
  15. package/lib/cjs/SectionMarkers.js +11 -7
  16. package/lib/cjs/SectionMarkers.js.map +1 -1
  17. package/lib/cjs/Tools.js +4 -4
  18. package/lib/cjs/Tools.js.map +1 -1
  19. package/lib/esm/HyperModeling.js +7 -4
  20. package/lib/esm/HyperModeling.js.map +1 -1
  21. package/lib/esm/HyperModelingDecorator.d.ts +1 -1
  22. package/lib/esm/HyperModelingDecorator.d.ts.map +1 -1
  23. package/lib/esm/HyperModelingDecorator.js +21 -9
  24. package/lib/esm/HyperModelingDecorator.js.map +1 -1
  25. package/lib/esm/PopupToolbar.js +13 -11
  26. package/lib/esm/PopupToolbar.js.map +1 -1
  27. package/lib/esm/SectionDrawingLocationState.js +28 -0
  28. package/lib/esm/SectionDrawingLocationState.js.map +1 -1
  29. package/lib/esm/SectionGraphicsProvider.d.ts.map +1 -1
  30. package/lib/esm/SectionGraphicsProvider.js +14 -0
  31. package/lib/esm/SectionGraphicsProvider.js.map +1 -1
  32. package/lib/esm/SectionMarkers.js +11 -7
  33. package/lib/esm/SectionMarkers.js.map +1 -1
  34. package/lib/esm/Tools.js +4 -4
  35. package/lib/esm/Tools.js.map +1 -1
  36. package/package.json +21 -21
@@ -84,6 +84,7 @@ class ProxyTreeSupplier {
84
84
  const proxyTreeSupplier = new ProxyTreeSupplier();
85
85
  /** A proxy for a 2d tile tree to be drawn in the context of a spatial view. */
86
86
  class ProxyTreeReference extends core_frontend_1.TileTreeReference {
87
+ _owner;
87
88
  constructor(id) {
88
89
  super();
89
90
  this._owner = id.state.iModel.tiles.getTileTreeOwner(id, proxyTreeSupplier);
@@ -112,6 +113,11 @@ class ProxyTreeReference extends core_frontend_1.TileTreeReference {
112
113
  }
113
114
  /** A proxy for a 2d tile tree to be drawn in the context of a spatial view. */
114
115
  class ProxyTree extends core_frontend_1.TileTree {
116
+ _rootTile;
117
+ _viewFlagOverrides;
118
+ tree;
119
+ ref;
120
+ symbologyOverrides;
115
121
  constructor(params, location, clipVolume) {
116
122
  const { tree, ref, view } = { ...params };
117
123
  super({
@@ -242,6 +248,8 @@ class ProxyTile extends core_frontend_1.Tile {
242
248
  }
243
249
  /** Draws the 2d section graphics into the 3d view. */
244
250
  class SectionGraphicsProvider {
251
+ _drawingRef;
252
+ _sheetRef;
245
253
  constructor(state, attachment) {
246
254
  this._drawingRef = new ProxyTreeReference({ state, attachment, isSheet: false });
247
255
  if (attachment)
@@ -252,6 +260,12 @@ class SectionGraphicsProvider {
252
260
  if (undefined !== this._sheetRef)
253
261
  func(this._sheetRef);
254
262
  }
263
+ *getReferences() {
264
+ yield this._drawingRef;
265
+ if (this._sheetRef) {
266
+ yield this._sheetRef;
267
+ }
268
+ }
255
269
  }
256
270
  /** Creates a TiledGraphicsProvider that can be associated with a [Viewport]($frontend) to display 2d section graphics and annotations in the context of a [SpatialViewState]($frontend).
257
271
  * Typically used indirectly via [[HyperModelingDecorator]].
@@ -1 +1 @@
1
- {"version":3,"file":"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xD,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 { assert, compareBooleans, compareStrings, Id64 } from \"@itwin/core-bentley\";\nimport { ClipShape, ClipVector, Point3d, Range3d, Transform } from \"@itwin/core-geometry\";\nimport { ColorDef, Placement2d, ViewAttachmentProps, ViewDefinition2dProps, ViewFlagOverrides } from \"@itwin/core-common\";\nimport {\n CategorySelectorState, DisclosedTileTreeSet, DisplayStyle2dState, DrawingViewState,\n FeatureSymbology, GeometricModel2dState, GraphicBranch, HitDetail, IModelApp, IModelConnection, RenderClipVolume, RenderSystem, SheetModelState, Tile, TileContent, TiledGraphicsProvider, TileDrawArgs,\n TileLoadPriority, TileRequest, TileRequestChannel, TileTree, TileTreeOwner, TileTreeReference, TileTreeSupplier, Viewport, ViewState2d,\n} from \"@itwin/core-frontend\";\nimport { SectionDrawingLocationState } from \"./SectionDrawingLocationState\";\nimport { HyperModeling } from \"./HyperModeling\";\n\ninterface ProxyTreeId {\n state: SectionDrawingLocationState;\n isSheet: boolean;\n attachment?: ViewAttachmentProps;\n}\n\ninterface ProxyTreeParams {\n tree: TileTree;\n ref: TileTreeReference;\n view: ViewState2d;\n state: SectionDrawingLocationState;\n attachment?: ViewAttachmentProps;\n}\n\nclass ProxyTreeSupplier implements TileTreeSupplier {\n public compareTileTreeIds(lhs: ProxyTreeId, rhs: ProxyTreeId): number {\n let cmp = compareBooleans(lhs.isSheet, rhs.isSheet);\n if (0 === cmp)\n cmp = compareStrings(lhs.state.id, rhs.state.id);\n\n return cmp;\n }\n\n public async createTileTree(id: ProxyTreeId, iModel: IModelConnection): Promise<TileTree | undefined> {\n let view;\n if (id.isSheet) {\n assert(undefined !== id.attachment);\n view = await this.createSheetViewState(id.state, id.attachment);\n } else {\n view = await id.state.tryLoadDrawingView();\n }\n\n if (undefined === view)\n return undefined;\n\n try {\n await iModel.models.load(view.baseModelId);\n const model = iModel.models.getLoaded(view.baseModelId);\n if (undefined === model || !(model instanceof GeometricModel2dState))\n return undefined;\n\n const treeRef = model.createTileTreeReference(view);\n const tree = await treeRef.treeOwner.loadTree();\n if (undefined === tree)\n return undefined;\n\n const ctor = id.isSheet ? SheetProxyTree : DrawingProxyTree;\n return new ctor({ tree, ref: treeRef, view, state: id.state, attachment: id.attachment });\n } catch {\n return undefined;\n }\n }\n\n private async createSheetViewState(state: SectionDrawingLocationState, attachment: ViewAttachmentProps): Promise<DrawingViewState | undefined> {\n assert(undefined !== state.viewAttachment);\n try {\n // A persistent view of the sheet doesn't necessarily exist, and we don't want a SheetViewState anyway.\n // All we want is to draw all the elements in the sheet (sans view attachments) clipped by the drawing boundary.\n // However, ModelState.createTileTreeReference() requires a ViewState.\n await state.iModel.models.load(attachment.model);\n const sheet = state.iModel.models.getLoaded(attachment.model);\n if (undefined === sheet || !(sheet instanceof SheetModelState))\n return undefined;\n\n const sheetExtents = await sheet.queryModelRange();\n const viewProps: ViewDefinition2dProps = {\n baseModelId: attachment.model,\n origin: { x: 0, y: 0 },\n delta: { x: sheetExtents.high.x, y: sheetExtents.high.y },\n angle: 0,\n categorySelectorId: Id64.invalid,\n displayStyleId: Id64.invalid,\n model: Id64.invalid,\n code: {\n spec: Id64.invalid,\n scope: Id64.invalid,\n },\n classFullName: DrawingViewState.classFullName,\n };\n\n const displayStyle = new DisplayStyle2dState({} as any, state.iModel);\n const categorySelector = new CategorySelectorState({} as any, state.iModel);\n\n return new DrawingViewState(viewProps, state.iModel, categorySelector, displayStyle, sheetExtents);\n } catch {\n return undefined;\n }\n }\n}\n\nconst proxyTreeSupplier = new ProxyTreeSupplier();\n\n/** A proxy for a 2d tile tree to be drawn in the context of a spatial view. */\nclass ProxyTreeReference extends TileTreeReference {\n private readonly _owner: TileTreeOwner;\n\n public constructor(id: ProxyTreeId) {\n super();\n this._owner = id.state.iModel.tiles.getTileTreeOwner(id, proxyTreeSupplier);\n }\n\n public override get castsShadows() {\n return false;\n }\n\n public override getClipVolume(tree: TileTree) {\n return true !== HyperModeling.graphicsConfig.ignoreClip ? super.getClipVolume(tree) : undefined;\n }\n\n public get treeOwner() { return this._owner; }\n\n private get _proxiedRef(): TileTreeReference | undefined {\n const proxiedTree = this.treeOwner.tileTree as ProxyTree;\n return undefined !== proxiedTree ? proxiedTree.ref : undefined;\n }\n\n public override discloseTileTrees(trees: DisclosedTileTreeSet): void {\n super.discloseTileTrees(trees);\n const ref = this._proxiedRef;\n if (undefined !== ref)\n ref.discloseTileTrees(trees);\n }\n\n public override async getToolTip(hit: HitDetail) {\n const ref = this._proxiedRef;\n return undefined !== ref ? ref.getToolTip(hit) : super.getToolTip(hit);\n }\n}\n\n/** A proxy for a 2d tile tree to be drawn in the context of a spatial view. */\nabstract class ProxyTree extends TileTree {\n private readonly _rootTile: ProxyTile;\n private readonly _viewFlagOverrides: ViewFlagOverrides;\n public readonly tree: TileTree;\n public readonly ref: TileTreeReference;\n public readonly symbologyOverrides: FeatureSymbology.Overrides;\n\n protected constructor(params: ProxyTreeParams, location: Transform, clipVolume: RenderClipVolume | undefined) {\n const { tree, ref, view } = { ...params };\n super({\n id: params.state.id,\n modelId: tree.modelId,\n iModel: tree.iModel,\n location,\n priority: TileLoadPriority.Primary,\n clipVolume,\n });\n\n this.tree = tree;\n this.ref = ref;\n this.symbologyOverrides = new FeatureSymbology.Overrides(view);\n\n const range = tree.iModelTransform.multiplyRange(tree.rootTile.range);\n const inverse = location.inverse();\n if (undefined !== inverse)\n inverse.multiplyRange(range, range);\n\n this._viewFlagOverrides = {\n ...view.viewFlags,\n lighting: false,\n // View clip (section clip) should not apply to 2d graphics.\n clipVolume: false,\n };\n\n this._rootTile = new ProxyTile(this, range);\n }\n\n public get rootTile(): ProxyTile { return this._rootTile; }\n public get viewFlagOverrides() { return this._viewFlagOverrides; }\n public get is3d() { return false; }\n public override get isContentUnbounded() { return false; }\n public get maxDepth() { return 1; }\n\n protected abstract get isDisplayed(): boolean;\n\n public draw(args: TileDrawArgs): void {\n if (!this.isDisplayed)\n return;\n\n const tiles = this.selectTiles(args);\n for (const tile of tiles)\n tile.drawGraphics(args);\n\n args.drawGraphics();\n }\n\n protected _selectTiles(_args: TileDrawArgs): Tile[] {\n return this.isDisplayed ? [this.rootTile] : [];\n }\n\n public prune(): void {\n // Our single tile is only a proxy. Our proxied tree(s) will be pruned separately\n }\n}\n\nclass DrawingProxyTree extends ProxyTree {\n public constructor(params: ProxyTreeParams) {\n const { state, attachment } = { ...params };\n const location = state.drawingToSpatialTransform.clone();\n\n let clipVolume;\n if (attachment) {\n assert(undefined !== state.viewAttachment);\n const clipJSON = attachment.jsonProperties?.clip;\n const clip = clipJSON ? ClipVector.fromJSON(clipJSON) : ClipVector.createEmpty();\n if (!clipJSON) {\n const placement = Placement2d.fromJSON(attachment.placement);\n const range = placement.calculateRange();\n clip.appendShape([\n Point3d.create(range.low.x, range.low.y),\n Point3d.create(range.high.x, range.low.y),\n Point3d.create(range.high.x, range.high.y),\n Point3d.create(range.low.x, range.high.y),\n ]);\n }\n\n if (clip.isValid) {\n const sheetToWorld = state.viewAttachment.transformToSpatial.clone();\n clip.transformInPlace(sheetToWorld);\n clipVolume = IModelApp.renderSystem.createClipVolume(clip);\n }\n }\n\n super(params, location, clipVolume);\n }\n\n protected get isDisplayed() { return true !== HyperModeling.graphicsConfig.hideSectionGraphics; }\n}\n\nclass SheetProxyTree extends ProxyTree {\n public constructor(params: ProxyTreeParams) {\n const { state, attachment } = { ...params };\n assert(undefined !== state.viewAttachment);\n assert(undefined !== attachment);\n const location = state.viewAttachment.transformToSpatial.clone();\n\n let clipVolume;\n if (state.viewAttachment.clip)\n clipVolume = IModelApp.renderSystem.createClipVolume(state.viewAttachment.clip);\n\n super(params, location, clipVolume);\n\n // Our view is manufactured. It draws everything regardless of subcategory.\n this.symbologyOverrides.ignoreSubCategory = true;\n }\n\n protected get isDisplayed() { return true !== HyperModeling.graphicsConfig.hideSheetAnnotations; }\n}\n\n/** The single Tile belonging to a ProxyTree, serving as a proxy for all of the proxied tree's tiles. */\nclass ProxyTile extends Tile {\n public constructor(tree: ProxyTree, range: Range3d) {\n super({ contentId: \"\", range, maximumSize: 512, isLeaf: true }, tree);\n this.setIsReady();\n }\n\n public get hasChildren() { return false; }\n public override get hasGraphics() { return true; }\n\n public get channel(): TileRequestChannel { throw new Error(\"Proxy tile has no content\"); }\n public async requestContent(_isCanceled: () => boolean): Promise<TileRequest.Response> { return undefined; }\n public async readContent(_data: TileRequest.ResponseData, _system: RenderSystem, _isCanceled?: () => boolean): Promise<TileContent> { return {}; }\n protected _loadChildren(_resolve: (children: Tile[]) => void, _reject: (error: Error) => void): void { }\n\n public override drawGraphics(args: TileDrawArgs) {\n const proxyTree = this.tree as ProxyTree;\n const sectionTree = proxyTree.tree;\n\n const location = proxyTree.iModelTransform.multiplyTransformTransform(sectionTree.iModelTransform);\n const clipVolume = true === proxyTree.viewFlagOverrides.clipVolume ? proxyTree.clipVolume : undefined;\n args = new TileDrawArgs({ context: args.context, location, tree: sectionTree, now: args.now, viewFlagOverrides: proxyTree.viewFlagOverrides, clipVolume, parentsAndChildrenExclusive: args.parentsAndChildrenExclusive, symbologyOverrides: proxyTree.symbologyOverrides });\n sectionTree.draw(args);\n\n const rangeGfx = this.getRangeGraphic(args.context);\n if (undefined !== rangeGfx)\n args.graphics.add(rangeGfx);\n\n if (true !== HyperModeling.graphicsConfig.debugClipVolumes || undefined === proxyTree.clipVolume)\n return;\n\n const builder = args.context.createSceneGraphicBuilder();\n builder.setSymbology(ColorDef.red, ColorDef.red, 2);\n for (const prim of proxyTree.clipVolume.clipVector.clips) {\n if (!(prim instanceof ClipShape))\n continue;\n\n const tf = prim.transformFromClip;\n const pts = prim.polygon.map((pt) => tf ? tf.multiplyPoint3d(pt) : pt.clone());\n builder.addLineString(pts);\n }\n\n const branch = new GraphicBranch();\n branch.entries.push(builder.finish());\n branch.setViewFlagOverrides({ clipVolume: false });\n args.context.outputGraphic(args.context.createGraphicBranch(branch, Transform.createIdentity()));\n }\n}\n\n/** Draws the 2d section graphics into the 3d view. */\nclass SectionGraphicsProvider implements TiledGraphicsProvider {\n private readonly _drawingRef: TileTreeReference;\n private readonly _sheetRef?: TileTreeReference;\n\n public constructor(state: SectionDrawingLocationState, attachment: ViewAttachmentProps | undefined) {\n this._drawingRef = new ProxyTreeReference({ state, attachment, isSheet: false });\n if (attachment)\n this._sheetRef = new ProxyTreeReference({ state, attachment, isSheet: true });\n }\n\n public forEachTileTreeRef(_viewport: Viewport, func: (ref: TileTreeReference) => void): void {\n func(this._drawingRef);\n if (undefined !== this._sheetRef)\n func(this._sheetRef);\n }\n}\n\n/** Creates a TiledGraphicsProvider that can be associated with a [Viewport]($frontend) to display 2d section graphics and annotations in the context of a [SpatialViewState]($frontend).\n * Typically used indirectly via [[HyperModelingDecorator]].\n * @param state The section drawing location specifying which section drawing to display.\n * @returns A provider suitable for passing to [Viewport.addTiledGraphicsProvider]($frontend).\n * @see [[HyperModelingDecorator.toggleAttachment]] to activate section graphics for a given [[SectionMarker]].\n * @public\n */\nexport async function createSectionGraphicsProvider(state: SectionDrawingLocationState): Promise<TiledGraphicsProvider> {\n let attachment;\n if (undefined !== state.viewAttachment) {\n const attachments = await state.iModel.elements.getProps(state.viewAttachment.id) as ViewAttachmentProps[];\n if (1 === attachments.length)\n attachment = attachments[0];\n }\n\n return new SectionGraphicsProvider(state, attachment);\n}\n"]}
1
+ {"version":3,"file":"SectionGraphicsProvider.js","sourceRoot":"","sources":["../../src/SectionGraphicsProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAuVH,sEASC;AA9VD,sDAAoF;AACpF,wDAA0F;AAC1F,oDAA0H;AAC1H,wDAI8B;AAE9B,mDAAgD;AAgBhD,MAAM,iBAAiB;IACd,kBAAkB,CAAC,GAAgB,EAAE,GAAgB;QAC1D,IAAI,GAAG,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AAC,KAAK,EAAE,UAAU,CAAC,CAAC;AACxD,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 { assert, compareBooleans, compareStrings, Id64 } from \"@itwin/core-bentley\";\nimport { ClipShape, ClipVector, Point3d, Range3d, Transform } from \"@itwin/core-geometry\";\nimport { ColorDef, Placement2d, ViewAttachmentProps, ViewDefinition2dProps, ViewFlagOverrides } from \"@itwin/core-common\";\nimport {\n CategorySelectorState, DisclosedTileTreeSet, DisplayStyle2dState, DrawingViewState,\n FeatureSymbology, GeometricModel2dState, GraphicBranch, HitDetail, IModelApp, IModelConnection, RenderClipVolume, RenderSystem, SheetModelState, Tile, TileContent, TiledGraphicsProvider, TileDrawArgs,\n TileLoadPriority, TileRequest, TileRequestChannel, TileTree, TileTreeOwner, TileTreeReference, TileTreeSupplier, Viewport, ViewState2d,\n} from \"@itwin/core-frontend\";\nimport { SectionDrawingLocationState } from \"./SectionDrawingLocationState\";\nimport { HyperModeling } from \"./HyperModeling\";\n\ninterface ProxyTreeId {\n state: SectionDrawingLocationState;\n isSheet: boolean;\n attachment?: ViewAttachmentProps;\n}\n\ninterface ProxyTreeParams {\n tree: TileTree;\n ref: TileTreeReference;\n view: ViewState2d;\n state: SectionDrawingLocationState;\n attachment?: ViewAttachmentProps;\n}\n\nclass ProxyTreeSupplier implements TileTreeSupplier {\n public compareTileTreeIds(lhs: ProxyTreeId, rhs: ProxyTreeId): number {\n let cmp = compareBooleans(lhs.isSheet, rhs.isSheet);\n if (0 === cmp)\n cmp = compareStrings(lhs.state.id, rhs.state.id);\n\n return cmp;\n }\n\n public async createTileTree(id: ProxyTreeId, iModel: IModelConnection): Promise<TileTree | undefined> {\n let view;\n if (id.isSheet) {\n assert(undefined !== id.attachment);\n view = await this.createSheetViewState(id.state, id.attachment);\n } else {\n view = await id.state.tryLoadDrawingView();\n }\n\n if (undefined === view)\n return undefined;\n\n try {\n await iModel.models.load(view.baseModelId);\n const model = iModel.models.getLoaded(view.baseModelId);\n if (undefined === model || !(model instanceof GeometricModel2dState))\n return undefined;\n\n const treeRef = model.createTileTreeReference(view);\n const tree = await treeRef.treeOwner.loadTree();\n if (undefined === tree)\n return undefined;\n\n const ctor = id.isSheet ? SheetProxyTree : DrawingProxyTree;\n return new ctor({ tree, ref: treeRef, view, state: id.state, attachment: id.attachment });\n } catch {\n return undefined;\n }\n }\n\n private async createSheetViewState(state: SectionDrawingLocationState, attachment: ViewAttachmentProps): Promise<DrawingViewState | undefined> {\n assert(undefined !== state.viewAttachment);\n try {\n // A persistent view of the sheet doesn't necessarily exist, and we don't want a SheetViewState anyway.\n // All we want is to draw all the elements in the sheet (sans view attachments) clipped by the drawing boundary.\n // However, ModelState.createTileTreeReference() requires a ViewState.\n await state.iModel.models.load(attachment.model);\n const sheet = state.iModel.models.getLoaded(attachment.model);\n if (undefined === sheet || !(sheet instanceof SheetModelState))\n return undefined;\n\n const sheetExtents = await sheet.queryModelRange();\n const viewProps: ViewDefinition2dProps = {\n baseModelId: attachment.model,\n origin: { x: 0, y: 0 },\n delta: { x: sheetExtents.high.x, y: sheetExtents.high.y },\n angle: 0,\n categorySelectorId: Id64.invalid,\n displayStyleId: Id64.invalid,\n model: Id64.invalid,\n code: {\n spec: Id64.invalid,\n scope: Id64.invalid,\n },\n classFullName: DrawingViewState.classFullName,\n };\n\n const displayStyle = new DisplayStyle2dState({} as any, state.iModel);\n const categorySelector = new CategorySelectorState({} as any, state.iModel);\n\n return new DrawingViewState(viewProps, state.iModel, categorySelector, displayStyle, sheetExtents);\n } catch {\n return undefined;\n }\n }\n}\n\nconst proxyTreeSupplier = new ProxyTreeSupplier();\n\n/** A proxy for a 2d tile tree to be drawn in the context of a spatial view. */\nclass ProxyTreeReference extends TileTreeReference {\n private readonly _owner: TileTreeOwner;\n\n public constructor(id: ProxyTreeId) {\n super();\n this._owner = id.state.iModel.tiles.getTileTreeOwner(id, proxyTreeSupplier);\n }\n\n public override get castsShadows() {\n return false;\n }\n\n public override getClipVolume(tree: TileTree) {\n return true !== HyperModeling.graphicsConfig.ignoreClip ? super.getClipVolume(tree) : undefined;\n }\n\n public get treeOwner() { return this._owner; }\n\n private get _proxiedRef(): TileTreeReference | undefined {\n const proxiedTree = this.treeOwner.tileTree as ProxyTree;\n return undefined !== proxiedTree ? proxiedTree.ref : undefined;\n }\n\n public override discloseTileTrees(trees: DisclosedTileTreeSet): void {\n super.discloseTileTrees(trees);\n const ref = this._proxiedRef;\n if (undefined !== ref)\n ref.discloseTileTrees(trees);\n }\n\n public override async getToolTip(hit: HitDetail) {\n const ref = this._proxiedRef;\n return undefined !== ref ? ref.getToolTip(hit) : super.getToolTip(hit);\n }\n}\n\n/** A proxy for a 2d tile tree to be drawn in the context of a spatial view. */\nabstract class ProxyTree extends TileTree {\n private readonly _rootTile: ProxyTile;\n private readonly _viewFlagOverrides: ViewFlagOverrides;\n public readonly tree: TileTree;\n public readonly ref: TileTreeReference;\n public readonly symbologyOverrides: FeatureSymbology.Overrides;\n\n protected constructor(params: ProxyTreeParams, location: Transform, clipVolume: RenderClipVolume | undefined) {\n const { tree, ref, view } = { ...params };\n super({\n id: params.state.id,\n modelId: tree.modelId,\n iModel: tree.iModel,\n location,\n priority: TileLoadPriority.Primary,\n clipVolume,\n });\n\n this.tree = tree;\n this.ref = ref;\n this.symbologyOverrides = new FeatureSymbology.Overrides(view);\n\n const range = tree.iModelTransform.multiplyRange(tree.rootTile.range);\n const inverse = location.inverse();\n if (undefined !== inverse)\n inverse.multiplyRange(range, range);\n\n this._viewFlagOverrides = {\n ...view.viewFlags,\n lighting: false,\n // View clip (section clip) should not apply to 2d graphics.\n clipVolume: false,\n };\n\n this._rootTile = new ProxyTile(this, range);\n }\n\n public get rootTile(): ProxyTile { return this._rootTile; }\n public get viewFlagOverrides() { return this._viewFlagOverrides; }\n public get is3d() { return false; }\n public override get isContentUnbounded() { return false; }\n public get maxDepth() { return 1; }\n\n protected abstract get isDisplayed(): boolean;\n\n public draw(args: TileDrawArgs): void {\n if (!this.isDisplayed)\n return;\n\n const tiles = this.selectTiles(args);\n for (const tile of tiles)\n tile.drawGraphics(args);\n\n args.drawGraphics();\n }\n\n protected _selectTiles(_args: TileDrawArgs): Tile[] {\n return this.isDisplayed ? [this.rootTile] : [];\n }\n\n public prune(): void {\n // Our single tile is only a proxy. Our proxied tree(s) will be pruned separately\n }\n}\n\nclass DrawingProxyTree extends ProxyTree {\n public constructor(params: ProxyTreeParams) {\n const { state, attachment } = { ...params };\n const location = state.drawingToSpatialTransform.clone();\n\n let clipVolume;\n if (attachment) {\n assert(undefined !== state.viewAttachment);\n const clipJSON = attachment.jsonProperties?.clip;\n const clip = clipJSON ? ClipVector.fromJSON(clipJSON) : ClipVector.createEmpty();\n if (!clipJSON) {\n const placement = Placement2d.fromJSON(attachment.placement);\n const range = placement.calculateRange();\n clip.appendShape([\n Point3d.create(range.low.x, range.low.y),\n Point3d.create(range.high.x, range.low.y),\n Point3d.create(range.high.x, range.high.y),\n Point3d.create(range.low.x, range.high.y),\n ]);\n }\n\n if (clip.isValid) {\n const sheetToWorld = state.viewAttachment.transformToSpatial.clone();\n clip.transformInPlace(sheetToWorld);\n clipVolume = IModelApp.renderSystem.createClipVolume(clip);\n }\n }\n\n super(params, location, clipVolume);\n }\n\n protected get isDisplayed() { return true !== HyperModeling.graphicsConfig.hideSectionGraphics; }\n}\n\nclass SheetProxyTree extends ProxyTree {\n public constructor(params: ProxyTreeParams) {\n const { state, attachment } = { ...params };\n assert(undefined !== state.viewAttachment);\n assert(undefined !== attachment);\n const location = state.viewAttachment.transformToSpatial.clone();\n\n let clipVolume;\n if (state.viewAttachment.clip)\n clipVolume = IModelApp.renderSystem.createClipVolume(state.viewAttachment.clip);\n\n super(params, location, clipVolume);\n\n // Our view is manufactured. It draws everything regardless of subcategory.\n this.symbologyOverrides.ignoreSubCategory = true;\n }\n\n protected get isDisplayed() { return true !== HyperModeling.graphicsConfig.hideSheetAnnotations; }\n}\n\n/** The single Tile belonging to a ProxyTree, serving as a proxy for all of the proxied tree's tiles. */\nclass ProxyTile extends Tile {\n public constructor(tree: ProxyTree, range: Range3d) {\n super({ contentId: \"\", range, maximumSize: 512, isLeaf: true }, tree);\n this.setIsReady();\n }\n\n public get hasChildren() { return false; }\n public override get hasGraphics() { return true; }\n\n public get channel(): TileRequestChannel { throw new Error(\"Proxy tile has no content\"); }\n public async requestContent(_isCanceled: () => boolean): Promise<TileRequest.Response> { return undefined; }\n public async readContent(_data: TileRequest.ResponseData, _system: RenderSystem, _isCanceled?: () => boolean): Promise<TileContent> { return {}; }\n protected _loadChildren(_resolve: (children: Tile[]) => void, _reject: (error: Error) => void): void { }\n\n public override drawGraphics(args: TileDrawArgs) {\n const proxyTree = this.tree as ProxyTree;\n const sectionTree = proxyTree.tree;\n\n const location = proxyTree.iModelTransform.multiplyTransformTransform(sectionTree.iModelTransform);\n const clipVolume = true === proxyTree.viewFlagOverrides.clipVolume ? proxyTree.clipVolume : undefined;\n args = new TileDrawArgs({ context: args.context, location, tree: sectionTree, now: args.now, viewFlagOverrides: proxyTree.viewFlagOverrides, clipVolume, parentsAndChildrenExclusive: args.parentsAndChildrenExclusive, symbologyOverrides: proxyTree.symbologyOverrides });\n sectionTree.draw(args);\n\n const rangeGfx = this.getRangeGraphic(args.context);\n if (undefined !== rangeGfx)\n args.graphics.add(rangeGfx);\n\n if (true !== HyperModeling.graphicsConfig.debugClipVolumes || undefined === proxyTree.clipVolume)\n return;\n\n const builder = args.context.createSceneGraphicBuilder();\n builder.setSymbology(ColorDef.red, ColorDef.red, 2);\n for (const prim of proxyTree.clipVolume.clipVector.clips) {\n if (!(prim instanceof ClipShape))\n continue;\n\n const tf = prim.transformFromClip;\n const pts = prim.polygon.map((pt) => tf ? tf.multiplyPoint3d(pt) : pt.clone());\n builder.addLineString(pts);\n }\n\n const branch = new GraphicBranch();\n branch.entries.push(builder.finish());\n branch.setViewFlagOverrides({ clipVolume: false });\n args.context.outputGraphic(args.context.createGraphicBranch(branch, Transform.createIdentity()));\n }\n}\n\n/** Draws the 2d section graphics into the 3d view. */\nclass SectionGraphicsProvider implements TiledGraphicsProvider {\n private readonly _drawingRef: TileTreeReference;\n private readonly _sheetRef?: TileTreeReference;\n\n public constructor(state: SectionDrawingLocationState, attachment: ViewAttachmentProps | undefined) {\n this._drawingRef = new ProxyTreeReference({ state, attachment, isSheet: false });\n if (attachment)\n this._sheetRef = new ProxyTreeReference({ state, attachment, isSheet: true });\n }\n\n public forEachTileTreeRef(_viewport: Viewport, func: (ref: TileTreeReference) => void): void {\n func(this._drawingRef);\n if (undefined !== this._sheetRef)\n func(this._sheetRef);\n }\n\n public * getReferences(): Iterable<TileTreeReference> {\n yield this._drawingRef;\n if (this._sheetRef) {\n yield this._sheetRef;\n }\n }\n}\n\n/** Creates a TiledGraphicsProvider that can be associated with a [Viewport]($frontend) to display 2d section graphics and annotations in the context of a [SpatialViewState]($frontend).\n * Typically used indirectly via [[HyperModelingDecorator]].\n * @param state The section drawing location specifying which section drawing to display.\n * @returns A provider suitable for passing to [Viewport.addTiledGraphicsProvider]($frontend).\n * @see [[HyperModelingDecorator.toggleAttachment]] to activate section graphics for a given [[SectionMarker]].\n * @public\n */\nexport async function createSectionGraphicsProvider(state: SectionDrawingLocationState): Promise<TiledGraphicsProvider> {\n let attachment;\n if (undefined !== state.viewAttachment) {\n const attachments = await state.iModel.elements.getProps(state.viewAttachment.id) as ViewAttachmentProps[];\n if (1 === attachments.length)\n attachment = attachments[0];\n }\n\n return new SectionGraphicsProvider(state, attachment);\n}\n"]}
@@ -21,6 +21,16 @@ const markerSize = core_geometry_1.Point2d.create(40, 40);
21
21
  * @public
22
22
  */
23
23
  class SectionMarker extends core_frontend_1.Marker {
24
+ /** The section drawing location state associated with the marker. */
25
+ state;
26
+ /** A description displayed as part of the tooltip when this marker is clustered with other markers. */
27
+ description;
28
+ /** @internal */
29
+ onMouseEnterEvent = new core_bentley_1.BeEvent();
30
+ /** @internal */
31
+ onMouseButtonEvent = new core_bentley_1.BeEvent();
32
+ /** @internal */
33
+ _isActive = false;
24
34
  /** Constructor, typically invoked indirectly via [[HyperModelingDecorator]].
25
35
  * @param state The section drawing location state this marker will represent.
26
36
  * @param pos The world coordinates at which to display the marker.
@@ -30,12 +40,6 @@ class SectionMarker extends core_frontend_1.Marker {
30
40
  */
31
41
  constructor(state) {
32
42
  super(state.placement.origin.clone(), markerSize);
33
- /** @internal */
34
- this.onMouseEnterEvent = new core_bentley_1.BeEvent();
35
- /** @internal */
36
- this.onMouseButtonEvent = new core_bentley_1.BeEvent();
37
- /** @internal */
38
- this._isActive = false;
39
43
  this.state = state;
40
44
  const data = HyperModeling_1.HyperModeling.getMarkerData(state.sectionType);
41
45
  this.description = data.label;
@@ -141,6 +145,7 @@ exports.SectionMarkerCluster = SectionMarkerCluster;
141
145
  * @public
142
146
  */
143
147
  class SectionMarkerSet extends core_frontend_1.MarkerSet {
148
+ minimumClusterSize = 5;
144
149
  /** Constructor
145
150
  * @param viewport The viewport in which the markers are to be displayed.
146
151
  * @param markers The markers to be displayed.
@@ -148,7 +153,6 @@ class SectionMarkerSet extends core_frontend_1.MarkerSet {
148
153
  */
149
154
  constructor(viewport, markers) {
150
155
  super(viewport);
151
- this.minimumClusterSize = 5;
152
156
  for (const marker of markers) {
153
157
  if (marker.state.iModel === viewport.iModel)
154
158
  this.markers.add(marker);
@@ -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;;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OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC5H,CAAC;IAED,mGAAmG;IAC5F,cAAc,CAAC,wBAAoC;QACxD,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO;YAC/B,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,wBAAwB;gBAC9C,OAAO,MAAM,CAAC;QAElB,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAnCD,4CAmCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module HyperModeling\n */\n\nimport { assert, BeEvent, Id64String } from \"@itwin/core-bentley\";\nimport { Point2d, Point3d, XAndY, XYAndZ } from \"@itwin/core-geometry\";\nimport { IModelReadRpcInterface } from \"@itwin/core-common\";\nimport {\n BeButton, BeButtonEvent, Cluster, DecorateContext, IModelApp, InputSource, Marker, MarkerImage, MarkerSet, ScreenViewport, ViewClipTool,\n} from \"@itwin/core-frontend\";\nimport { SectionDrawingLocationState } from \"./SectionDrawingLocationState\";\nimport { HyperModeling } from \"./HyperModeling\";\n\nconst markerSize = Point2d.create(40, 40);\n\n/** A [Marker]($frontend) associated with a [[SectionDrawingLocationState]], displayed as a canvas decoration at the location of the section.\n * Clicking on the marker toggles display of the section graphics. Mousing over the marker produces a toolbar with additional interactions.\n * @see [[HyperModelingDecorator]] for a [Decorator]($frontend) capable of displaying section markers for each section drawing location.\n * @see [[SectionMarkerHandler]] to customize the marker interactions.\n * @public\n */\nexport class SectionMarker extends Marker {\n /** The section drawing location state associated with the marker. */\n public readonly state: SectionDrawingLocationState;\n /** A description displayed as part of the tooltip when this marker is clustered with other markers. */\n public readonly description: string;\n /** @internal */\n public readonly onMouseEnterEvent = new BeEvent<(marker: SectionMarker) => void>();\n /** @internal */\n public readonly onMouseButtonEvent = new BeEvent<(marker: SectionMarker) => void>();\n /** @internal */\n private _isActive = false;\n\n /** Constructor, typically invoked indirectly via [[HyperModelingDecorator]].\n * @param state The section drawing location state this marker will represent.\n * @param pos The world coordinates at which to display the marker.\n * @param description A brief description of this marker, used as part of the tooltip when this marker is part of a cluster.\n * @param icon The icon displayed by the marker.\n * @param tooltip Optional detailed tooltip displayed on mouse hover. If undefined, the `description` is used instead.\n */\n public constructor(state: SectionDrawingLocationState) {\n super(state.placement.origin.clone(), markerSize);\n this.state = state;\n\n const data = HyperModeling.getMarkerData(state.sectionType);\n this.description = data.label;\n if (data.image)\n this.setImage(data.image);\n\n this.setScaleFactor({ low: .2, high: 1.4 }); // make size 20% at back of frustum and 140% at front of frustum (if camera is on)\n }\n\n /** @internal */\n public get isHilited(): boolean { return this._isHilited; }\n\n /** Returns true if this is the \"active\" section marker. At most one marker is active at a given time.\n * @see [[HyperModelingDecorator.activeMarker]].\n * @see [[HyperModelingDecorator.setActiveMarker]].\n * @see [[SectionMarkerHandler.toggleMarker]].\n */\n public get isActive(): boolean {\n return this._isActive;\n }\n\n /** @internal */\n public setActive(active: boolean): void {\n this._isActive = active;\n }\n\n /** @internal */\n protected drawActive(ctx: CanvasRenderingContext2D) {\n ctx.shadowBlur = 30;\n ctx.shadowColor = \"gold\";\n return false;\n }\n\n /** @internal */\n public override drawDecoration(ctx: CanvasRenderingContext2D): void {\n if (!this.isActive || !this.drawActive(ctx))\n super.drawDecoration(ctx);\n }\n\n /** @internal */\n public override onMouseEnter(ev: BeButtonEvent) {\n // Lazily load the tooltip.\n if (undefined === this.title) {\n IModelReadRpcInterface.getClientForRouting(this.state.iModel.routingContext.token).getToolTipMessage(this.state.iModel.getRpcProps(), this.state.id).then((tooltipMsg) => {\n this.title = IModelApp.formatElementToolTip(tooltipMsg);\n }).catch((_) => {\n this.title = this.description;\n });\n }\n\n super.onMouseEnter(ev);\n this.onMouseEnterEvent.raiseEvent(this);\n }\n\n /** @internal */\n public override onMouseButton(ev: BeButtonEvent): boolean {\n if (InputSource.Mouse === ev.inputSource && BeButton.Data === ev.button && ev.isDown && ev.viewport)\n this.onMouseButtonEvent.raiseEvent(this);\n\n return true; // Don't allow clicks to be sent to active tool...\n }\n\n /** @internal */\n public override addMarker(context: DecorateContext) {\n super.addMarker(context);\n if (this.isHilited)\n ViewClipTool.drawClip(context, this.state.clip, undefined, { fillClipPlanes: true, hasPrimaryPlane: true });\n }\n}\n\n/** A Marker used to show a cluster of section locations.\n * @internal\n */\nexport class SectionMarkerCluster extends Marker {\n /** Create a new cluster marker */\n constructor(location: XYAndZ, size: XAndY, cluster: Cluster<SectionMarker>, image: MarkerImage | Promise<MarkerImage> | undefined) {\n super(location, size);\n\n this.imageOffset = new Point3d(0, 30);\n this.label = cluster.markers.length.toLocaleString();\n this.labelColor = \"black\";\n this.labelFont = \"bold 14px sans-serif\";\n\n const maxLen = 10;\n let title = \"\";\n cluster.markers.forEach((marker, index: number) => {\n if (index < maxLen) {\n if (title !== \"\")\n title += \"<br>\";\n title += marker.description;\n }\n });\n\n if (cluster.markers.length > maxLen)\n title += \"<br>...\";\n\n const div = document.createElement(\"div\");\n div.innerHTML = title;\n this.title = div;\n if (image)\n this.setImage(image);\n }\n\n /** Show the cluster as a white circle with an outline */\n public override drawFunc(ctx: CanvasRenderingContext2D): void {\n ctx.beginPath();\n ctx.strokeStyle = \"#372528\";\n ctx.fillStyle = \"white\";\n ctx.lineWidth = 5;\n ctx.arc(0, 0, 13, 0, Math.PI * 2);\n ctx.fill();\n ctx.stroke();\n }\n\n public override onMouseButton(_ev: BeButtonEvent): boolean { return true; } // Don't allow clicks to be sent to active tool...\n}\n\n/** A [MarkerSet]($frontend) containing [[SectionMarker]]s identifying [SectionDrawingLocation]($backend)s within a spatial view.\n * Typically used indirectly via [[HyperModelingDecorator]].\n * @public\n */\nexport class SectionMarkerSet extends MarkerSet<SectionMarker> {\n public override minimumClusterSize = 5;\n\n /** Constructor\n * @param viewport The viewport in which the markers are to be displayed.\n * @param markers The markers to be displayed.\n * @note Each marker's [[SectionDrawingLocationState]] must be associated with the same [IModelConnection]($frontend) as the viewport; any markers from other iModels will be omitted.\n */\n public constructor(viewport: ScreenViewport, markers: SectionMarker[]) {\n super(viewport);\n for (const marker of markers) {\n if (marker.state.iModel === viewport.iModel)\n this.markers.add(marker);\n }\n }\n\n /** The viewport in which the markers are to be displayed. */\n public override get viewport(): ScreenViewport {\n assert(undefined !== super.viewport);\n return super.viewport;\n }\n\n /** @internal */\n protected getClusterMarker(cluster: Cluster<SectionMarker>): Marker {\n return new SectionMarkerCluster(cluster.getClusterLocation(), cluster.markers[0].size, cluster, cluster.markers[0].image);\n }\n\n /** Find the SectionMarker corresponding to the specified [SectionDrawingLocation]($backend) Id. */\n public findMarkerById(sectionDrawingLocationId: Id64String): SectionMarker | undefined {\n for (const marker of this.markers)\n if (marker.state.id === sectionDrawingLocationId)\n return marker;\n\n return undefined;\n }\n}\n"]}
1
+ {"version":3,"file":"SectionMarkers.js","sourceRoot":"","sources":["../../src/SectionMarkers.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAkE;AAClE,wDAAuE;AACvE,oDAA4D;AAC5D,wDAE8B;AAE9B,mDAAgD;AAEhD,MAAM,UAAU,GAAG,uBAAO,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAE1C;;;;;GAKG;AACH,MAAa,aAAc,SAAQ,sBAAM;IACvC,qEAAqE;IACrD,KAAK,CAA8B;IACnD,uGAAuG;IACvF,WAAW,CAAS;IACpC,gBAAgB;IACA,iBAAiB,GAAG,IAAI,sBAAO,EAAmC,CAAC;IACnF,gBAAgB;IACA,kBAAkB,GAAG,IAAI,sBAAO,EAAmC,CAAC;IACpF,gBAAgB;IACR,SAAS,GAAG,KAAK,CAAC;IAE1B;;;;;;OAMG;IACH,YAAmB,KAAkC;QACnD,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,UAAU,C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AG,CAAC,CAAC,CAAC;QAClC,GAAG,CAAC,IAAI,EAAE,CAAC;QACX,GAAG,CAAC,MAAM,EAAE,CAAC;IACf,CAAC;IAEe,aAAa,CAAC,GAAkB,IAAa,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,kDAAkD;CAC/H;AA1CD,oDA0CC;AAED;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,yBAAwB;IAC5C,kBAAkB,GAAG,CAAC,CAAC;IAEvC;;;;OAIG;IACH,YAAmB,QAAwB,EAAE,OAAwB;QACnE,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChB,KAAK,MAAM,MAAM,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
@@ -24,6 +24,7 @@ function parseToggle(arg) {
24
24
  }
25
25
  }
26
26
  class HyperModelingTool extends core_frontend_1.Tool {
27
+ static toolId = "HyperModeling";
27
28
  static get minArgs() { return 0; }
28
29
  static get maxArgs() { return 1; }
29
30
  async run(enable, vp) {
@@ -37,7 +38,6 @@ class HyperModelingTool extends core_frontend_1.Tool {
37
38
  return typeof enable !== "string" && this.run(enable);
38
39
  }
39
40
  }
40
- HyperModelingTool.toolId = "HyperModeling";
41
41
  /** Configures how section graphics are displayed. These are global settings. If no arguments are supplied, the defaults are restored.
42
42
  * Otherwise, each argument is of the form "name=value" where value is 0 (disable) or 1 (enable). Only the first letter of each argument matters.
43
43
  * - drawings: Whether to display the section drawing graphics. Default: 1.
@@ -46,6 +46,7 @@ HyperModelingTool.toolId = "HyperModeling";
46
46
  * - boundaries: Whether to display clip volumes as boundary shapes for debugging purposes. Default: 0.
47
47
  */
48
48
  class SectionGraphicsConfigTool extends core_frontend_1.Tool {
49
+ static toolId = "HyperModeling.Graphics.Config";
49
50
  static get minArgs() { return 0; }
50
51
  static get maxArgs() { return 4; }
51
52
  async run(config) {
@@ -90,7 +91,6 @@ class SectionGraphicsConfigTool extends core_frontend_1.Tool {
90
91
  return this.run(config);
91
92
  }
92
93
  }
93
- SectionGraphicsConfigTool.toolId = "HyperModeling.Graphics.Config";
94
94
  class SectionMarkerConfigTool extends core_frontend_1.Tool {
95
95
  static get minArgs() { return 0; }
96
96
  static get maxArgs() { return 3; }
@@ -145,12 +145,13 @@ class SectionMarkerConfigTool extends core_frontend_1.Tool {
145
145
  }
146
146
  }
147
147
  class SectionMarkerDefaultConfigTool extends SectionMarkerConfigTool {
148
+ static toolId = "HyperModeling.Marker.Default.Config";
148
149
  update(config) {
149
150
  HyperModeling_1.HyperModeling.updateConfiguration({ markers: config });
150
151
  }
151
152
  }
152
- SectionMarkerDefaultConfigTool.toolId = "HyperModeling.Marker.Default.Config";
153
153
  class SectionMarkerDecoratorConfigTool extends SectionMarkerConfigTool {
154
+ static toolId = "HyperModeling.Marker.Config";
154
155
  update(config) {
155
156
  const vp = core_frontend_1.IModelApp.viewManager.selectedView;
156
157
  const decorator = vp ? HyperModelingDecorator_1.HyperModelingDecorator.getForViewport(vp) : undefined;
@@ -158,7 +159,6 @@ class SectionMarkerDecoratorConfigTool extends SectionMarkerConfigTool {
158
159
  decorator.updateConfiguration(config);
159
160
  }
160
161
  }
161
- SectionMarkerDecoratorConfigTool.toolId = "HyperModeling.Marker.Config";
162
162
  /** @internal */
163
163
  function registerTools(namespace) {
164
164
  const register = (tool) => core_frontend_1.IModelApp.tools.register(tool, namespace);
@@ -1 +1 @@
1
- {"version":3,"file":"Tools.js","sourceRoot":"","sources":["../../src/Tools.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AA0LH,sCAMC;AA9LD,oDAAiD;AACjD,wDAAuE;AACvE,mDAAgD;AAEhD,qEAAkE;AAElE,gKAAgK;AAChK,SAAS,WAAW,CAAC,GAAuB;IAC1C,IAAI,SAAS,KAAK,GAAG;QACnB,OAAO,SAAS,CAAC;IAEnB,QAAQ,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC;QAC1B,KAAK,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC;QACvB,KAAK,KAAK,CAAC,CAAC,OAAO,KAAK,CAAC;QACzB,KAAK,QAAQ,CAAC,CAAC,OAAO,SAAS,CAAC;QAChC,OAAO,CAAC,CAAC,OAAO,GAAG,CAAC;IACtB,CAAC;AACH,CAAC;AAED,MAAM,iBAAkB,SA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6B,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
+ {"version":3,"file":"Tools.js","sourceRoot":"","sources":["../../src/Tools.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AA0LH,sCAMC;AA9LD,oDAAiD;AACjD,wDAAuE;AACvE,mDAAgD;AAEhD,qEAAkE;AAElE,gKAAgK;AAChK,SAAS,WAAW,CAAC,GAAuB;IAC1C,IAAI,SAAS,KAAK,GAAG;QACnB,OAAO,SAAS,CAAC;IAEnB,QAAQ,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC;QAC1B,KAAK,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC;QACvB,KAAK,KAAK,CAAC,CAAC,OAAO,KAAK,CAAC;QACzB,KAAK,QAAQ,CAAC,CAAC,OAAO,SAAS,CAAC;QAChC,OAAO,CAAC,CAAC,OAAO,GAAG,CAAC;IACtB,CAAC;AACH,CAAC;AAED,MAAM,iBAAkB,SAAQ,oBAAI;IAC3B,MAAM,CAAU,MAAM,GAAG,eAAe,CAAC;IACzC,MAAM,KAAc,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3C,MAAM,KAAc,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IAElC,KAAK,CAAC,GAAG,CAAC,MAAgB,EAAE,EAAmB;QAC7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C,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"]}
@@ -22,6 +22,11 @@ function assertInitialized(maybe) {
22
22
  * @public
23
23
  */
24
24
  export class HyperModeling {
25
+ /** @internal */
26
+ static resources;
27
+ static _markerHandler;
28
+ static _markerConfig = {};
29
+ static _graphicsConfig = {};
25
30
  static shutdown() {
26
31
  this.resources = undefined;
27
32
  this._markerHandler = undefined;
@@ -172,7 +177,7 @@ export class HyperModeling {
172
177
  return this._start(viewport);
173
178
  }
174
179
  else {
175
- decorator?.dispose();
180
+ decorator?.[Symbol.dispose]();
176
181
  return undefined;
177
182
  }
178
183
  }
@@ -207,7 +212,7 @@ export class HyperModeling {
207
212
  */
208
213
  static stop(viewport) {
209
214
  const decorator = HyperModelingDecorator.getForViewport(viewport);
210
- decorator?.dispose();
215
+ decorator?.[Symbol.dispose]();
211
216
  }
212
217
  /** @internal */
213
218
  static get namespace() {
@@ -229,6 +234,4 @@ export class HyperModeling {
229
234
  }
230
235
  }
231
236
  }
232
- HyperModeling._markerConfig = {};
233
- HyperModeling._graphicsConfig = {};
234
237
  //# sourceMappingURL=HyperModeling.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"HyperModeling.js","sourceRoot":"","sources":["../../src/HyperModeling.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAoC,sBAAsB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtH,OAAO,EAAE,aAAa,EAAE,MAAM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AS,CAAC,SAAS,CAAC;IAClC,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,aAAa,CAAC,IAAiB;QAC3C,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACxB,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,WAAW,CAAC,IAAI;gBACnB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;YACrC,KAAK,WAAW,CAAC,SAAS;gBACxB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC;YAC1C,KAAK,WAAW,CAAC,MAAM;gBACrB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC;YACvC;gBACE,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC;QAC1C,CAAC;IACH,CAAC;;AA5Oc,2BAAa,GAAwB,EAAE,CAAC;AACxC,6BAAe,GAA0B,EAAE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module HyperModeling\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { SectionType } from \"@itwin/core-common\";\r\nimport { IModelApp, IModelConnection, ScreenViewport, tryImageElementFromUrl, ViewManip } from \"@itwin/core-frontend\";\r\nimport { registerTools } from \"./Tools\";\r\nimport { HyperModelingDecorator } from \"./HyperModelingDecorator\";\r\nimport { HyperModelingConfig, SectionGraphicsConfig, SectionMarkerConfig } from \"./HyperModelingConfig\";\r\nimport { SectionMarkerHandler } from \"./SectionMarkerHandler\";\r\n\r\n/** @internal */\r\nexport interface MarkerData {\r\n readonly label: string;\r\n readonly image: HTMLImageElement | undefined;\r\n}\r\n\r\ninterface Resources {\r\n readonly namespace?: string;\r\n readonly markers: {\r\n readonly section: MarkerData;\r\n readonly plan: MarkerData;\r\n readonly elevation: MarkerData;\r\n readonly detail: MarkerData;\r\n };\r\n}\r\n\r\ninterface MaybeInitialized {\r\n resources?: Resources;\r\n}\r\n\r\ninterface Initialized {\r\n resources: Resources;\r\n}\r\n\r\nfunction assertInitialized(maybe: MaybeInitialized): asserts maybe is Initialized {\r\n if (undefined === maybe.resources)\r\n throw new Error(\"You must call HyperModeling.initialize before using the hypermodeling package\");\r\n}\r\n\r\n/** The API entry point for the hypermodeling package. Applications must call [[initialize]] and await the result before using the package.\r\n * The behavior of the package can be customized via a [[HyperModelingConfig]] supplied to [[initialize]], [[updateConfiguration]], or [[replaceConfiguration]].\r\n * Hypermodeling mode can be enabled or disabled via [[startOrStop]], which returns a [[HyperModelingDecorator]] when enabling hypermodeling.\r\n * Consult the package's `README.md` for a description of the available functionality.\r\n * @public\r\n */\r\nexport class HyperModeling {\r\n /** @internal */\r\n public static resources?: Resources;\r\n private static _markerHandler?: SectionMarkerHandler;\r\n private static _markerConfig: SectionMarkerConfig = {};\r\n private static _graphicsConfig: SectionGraphicsConfig = {};\r\n\r\n private static shutdown() {\r\n this.resources = undefined;\r\n this._markerHandler = undefined;\r\n this._markerConfig = {};\r\n this._graphicsConfig = {};\r\n }\r\n\r\n /** Returns whether the hypermodeling package is initialized.\r\n * @see [[HyperModeling.initialize]] to initialize the package.\r\n */\r\n public static get isInitialized(): boolean {\r\n return undefined !== this.resources;\r\n }\r\n\r\n /** Invoke this method to initialize the hypermodeling package for use. You *must* await the result before using any of this package's APIs.\r\n * Typically an application would invoke this after [IModelApp.startup]($frontend), e.g.,\r\n * ```ts\r\n * await IModelApp.startup();\r\n * await HyperModeling.initialize();\r\n * ```\r\n * Calling this method again after the first initialization behaves the same as calling [[HyperModeling.replaceConfiguration]].\r\n * @note The hypermodeling package will be reset to uninitialized after [IModelApp.shutdown]($frontend) is invoked.\r\n * @see [[replaceConfiguration]] and [[updateConfiguration]] to modify the configuration after initialization.\r\n */\r\n public static async initialize(config?: HyperModelingConfig): Promise<void> {\r\n if (undefined !== this.resources) {\r\n this.replaceConfiguration(config);\r\n return;\r\n }\r\n\r\n // clean up if we're being shut down\r\n IModelApp.onBeforeShutdown.addListener(() => this.shutdown());\r\n\r\n const namespace = \"HyperModeling\";\r\n await IModelApp.localization.registerNamespace(namespace);\r\n\r\n const loadImages = [\r\n tryImageElementFromUrl(`${IModelApp.publicPath}section-marker.svg`),\r\n tryImageElementFromUrl(`${IModelApp.publicPath}detail-marker.svg`),\r\n tryImageElementFromUrl(`${IModelApp.publicPath}elevation-marker.svg`),\r\n tryImageElementFromUrl(`${IModelApp.publicPath}plan-marker.svg`),\r\n ];\r\n\r\n const images = await Promise.all(loadImages);\r\n this.resources = {\r\n namespace,\r\n markers: {\r\n section: { image: images[0], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.SectionCallout\") },\r\n detail: { image: images[1], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.DetailCallout\") },\r\n elevation: { image: images[2], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.ElevationCallout\") },\r\n plan: { image: images[3], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.PlanCallout\") },\r\n },\r\n };\r\n\r\n registerTools(namespace);\r\n this.replaceConfiguration(config);\r\n }\r\n\r\n private static async ensureInitialized(): Promise<void> {\r\n if (undefined === this.resources)\r\n await this.initialize();\r\n\r\n assertInitialized(this);\r\n }\r\n\r\n /** Replaces the current package configuration, overwriting all previous settings. Passing `undefined` resets all settings to defaults.\r\n * @see [[HyperModeling.updateConfiguration]] for overriding specific aspects of the configuration.\r\n */\r\n public static replaceConfiguration(config?: HyperModelingConfig): void {\r\n config = config ?? {};\r\n this._markerHandler = config.markerHandler ?? new SectionMarkerHandler();\r\n this._markerConfig = config.markers ? { ...config.markers } : {};\r\n this._graphicsConfig = config.graphics ? { ...config.graphics } : {};\r\n }\r\n\r\n /** Overrides specific aspects of the current package configuration. Any field that is not `undefined` will be replaced in the current configuration;\r\n * the rest will retain their current values.\r\n * @see [[HyperModeling.replaceConfiguration]].\r\n */\r\n public static updateConfiguration(config: HyperModelingConfig): void {\r\n this._markerHandler = config.markerHandler ?? this._markerHandler;\r\n\r\n if (config.markers) {\r\n this._markerConfig = {\r\n ignoreModelSelector: config.markers.ignoreModelSelector ?? this._markerConfig.ignoreModelSelector,\r\n ignoreCategorySelector: config.markers.ignoreCategorySelector ?? this._markerConfig.ignoreCategorySelector,\r\n hiddenSectionTypes: config.markers.hiddenSectionTypes ?? this._markerConfig.hiddenSectionTypes,\r\n };\r\n }\r\n\r\n if (config.graphics) {\r\n this._graphicsConfig = {\r\n ignoreClip: config.graphics.ignoreClip ?? this._graphicsConfig.ignoreClip,\r\n debugClipVolumes: config.graphics.debugClipVolumes ?? this._graphicsConfig.debugClipVolumes,\r\n hideSectionGraphics: config.graphics.hideSectionGraphics ?? this._graphicsConfig.hideSectionGraphics,\r\n hideSheetAnnotations: config.graphics.hideSheetAnnotations ?? this._graphicsConfig.hideSheetAnnotations,\r\n };\r\n\r\n IModelApp.viewManager.invalidateViewportScenes();\r\n }\r\n }\r\n\r\n /** The handler that defines interactions with [[SectionMarker]]s.\r\n * @see [[initialize]] to override the default handler at package initialization.\r\n * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current handler.\r\n */\r\n public static get markerHandler(): SectionMarkerHandler {\r\n assertInitialized(this);\r\n assert(undefined !== this._markerHandler);\r\n return this._markerHandler;\r\n }\r\n\r\n /** The current marker display configuration applied to any newly-created [[HyperModelingDecorator]]s.\r\n * @see [[initialize]] to override the default configuration at package initialization.\r\n * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current configuration.\r\n * @see [[HyperModelingDecorator.replaceConfiguration]] or [[HyperModelingDecorator.updateConfiguration]] to change the configuration for an existing decorator.\r\n */\r\n public static get markerConfig(): SectionMarkerConfig {\r\n return this._markerConfig;\r\n }\r\n\r\n /** This graphics options applied to graphics displayed by all [[HyperModelingDecorator]]s.\r\n * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current configuration.\r\n */\r\n public static get graphicsConfig(): SectionGraphicsConfig {\r\n return this._graphicsConfig;\r\n }\r\n\r\n /** Returns true if the specified iModel contains any [SectionDrawingLocation]($backend)s. Hypermodeling is based on section drawing locations,\r\n * so if none are present, hypermodeling features are not relevant to the iModel. Attempting to use those features with such an iModel is fine,\r\n * but probably not useful.\r\n */\r\n public static async isSupportedForIModel(imodel: IModelConnection): Promise<boolean> {\r\n try {\r\n const reader = imodel.createQueryReader(\"SELECT ECInstanceId FROM bis.SectionDrawingLocation LIMIT 1\");\r\n return await reader.step(); // i.e., are any results are returned?\r\n } catch {\r\n // An iModel with a version of BisCore older than 1.0.11 will produce an expected \"table not found\" on the SectionDrawingLocation ECClass.\r\n return false;\r\n }\r\n }\r\n\r\n /** Returns whether hypermodeling is currently enabled for the specified viewport.\r\n * @see [[startOrStop]] to enable or disable hypermodeling for a viewport.\r\n */\r\n public static isEnabledForViewport(viewport: ScreenViewport): boolean {\r\n return undefined !== HyperModelingDecorator.getForViewport(viewport);\r\n }\r\n\r\n /** Start or stop hypermodeling mode for the specified viewport.\r\n * Enabling hypermodeling registers and returns a [[HyperModelingDecorator]] to display [[SectionMarker]]s within the viewport.\r\n * Disabling hypermodeling removes that decorator.\r\n * @param viewport The hypermodeling viewport\r\n * @param start `true` to enter hypermodeling mode, `false` to exit, or `undefined` to toggle the current mode.\r\n * @returns The new decorator is hypermodeling was successfully enabled.\r\n * @note Enabling hypermodeling may fail if the viewport is not viewing a spatial model or if the viewport's iModel does not support hypermodeling.\r\n * @see [[start]] and [[stop]].\r\n * @see [[isSupportedForIModel]].\r\n */\r\n public static async startOrStop(viewport: ScreenViewport, start?: boolean): Promise<HyperModelingDecorator | undefined> {\r\n // Help out the caller since we're async anyway...\r\n await this.ensureInitialized();\r\n\r\n const decorator = HyperModelingDecorator.getForViewport(viewport);\r\n if (undefined === start)\r\n start = undefined === decorator;\r\n\r\n if (start) {\r\n return this._start(viewport);\r\n } else {\r\n decorator?.dispose();\r\n return undefined;\r\n }\r\n }\r\n\r\n /** Start hypermodeling mode for the specified viewport if it is not currently enabled.\r\n * If hypermodeling is already enabled for the viewport, the existing decorator is returned; otherwise, a new decorator is created.\r\n * @param viewport The viewport for which to enable hypermodeling\r\n * @returns The decorator that implements hypermodeling features for the viewport, or `undefined` if hypermodeling could not be enabled.\r\n * @note Enabling hypermodeling may fail if the viewport is not viewing a spatial model or if the viewport's iModel does not support hypermodeling.\r\n */\r\n public static async start(viewport: ScreenViewport): Promise<HyperModelingDecorator | undefined> {\r\n await this.ensureInitialized();\r\n return this._start(viewport);\r\n }\r\n\r\n private static async _start(viewport: ScreenViewport): Promise<HyperModelingDecorator | undefined> {\r\n assertInitialized(this);\r\n if (!viewport.view.isSpatialView())\r\n return undefined;\r\n\r\n let decorator = HyperModelingDecorator.getForViewport(viewport);\r\n if (!decorator)\r\n decorator = await HyperModelingDecorator.create(viewport, this._markerConfig);\r\n\r\n if (undefined !== decorator && viewport.view.isCameraOn) {\r\n // We want the 2d graphics to align with the 3d geometry. Perspective ruins that.\r\n viewport.view.turnCameraOff();\r\n ViewManip.fitView(viewport, false, { noSaveInUndo: true });\r\n viewport.clearViewUndo();\r\n }\r\n\r\n return decorator;\r\n }\r\n\r\n /** Stop hypermodeling mode for the specified viewport if it is currently enabled. This disposes of the [[HyperModelingDecorator]] associated with the viewport.\r\n * @see [[start]] to enable hypermodeling for a viewport.\r\n * @see [[startOrStop]] to toggle hypermodeling mode.\r\n */\r\n public static stop(viewport: ScreenViewport): void {\r\n const decorator = HyperModelingDecorator.getForViewport(viewport);\r\n decorator?.dispose();\r\n }\r\n\r\n /** @internal */\r\n public static get namespace(): string | undefined {\r\n assertInitialized(this);\r\n return this.resources.namespace;\r\n }\r\n\r\n /** @internal */\r\n public static getMarkerData(type: SectionType): MarkerData {\r\n assertInitialized(this);\r\n switch (type) {\r\n case SectionType.Plan:\r\n return this.resources.markers.plan;\r\n case SectionType.Elevation:\r\n return this.resources.markers.elevation;\r\n case SectionType.Detail:\r\n return this.resources.markers.detail;\r\n default:\r\n return this.resources.markers.section;\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"HyperModeling.js","sourceRoot":"","sources":["../../src/HyperModeling.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAoC,sBAAsB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtH,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AA0B9D,SAAS,iBAAiB,CAAC,KAAuB;IAChD,IAAI,SAAS,KAAK,KAAK,CAAC,SAAS;QAC/B,MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;AACrG,CAAC;AAED;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IACxB,gBAAgB;IACT,MAAM,CAAC,SAAS,CAAa;IAC5B,MAAM,CAAC,cAAc,CAAwB;IAC7C,MAAM,CAAC,aAAa,GAAwB,EAAE,CAAC;IAC/C,MAAM,CAAC,eAAe,GAA0B,EAAE,CAAC;IAEnD,MAAM,CAAC,QAAQ;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;QAChC,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;QACxB,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACI,MAAM,KAAK,aAAa;QAC7B,OAAO,SAAS,KAAK,IAAI,CAAC,SAAS,CAAC;IACtC,CAAC;IAED;;;;;;;;;OASG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC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F,IAAI,SAAS,KAAK,SAAS,IAAI,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACxD,iFAAiF;YACjF,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YAC9B,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;YAC3D,QAAQ,CAAC,aAAa,EAAE,CAAC;QAC3B,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,IAAI,CAAC,QAAwB;QACzC,MAAM,SAAS,GAAG,sBAAsB,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAClE,SAAS,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAChC,CAAC;IAED,gBAAgB;IACT,MAAM,KAAK,SAAS;QACzB,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;IAClC,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,aAAa,CAAC,IAAiB;QAC3C,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACxB,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,WAAW,CAAC,IAAI;gBACnB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;YACrC,KAAK,WAAW,CAAC,SAAS;gBACxB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC;YAC1C,KAAK,WAAW,CAAC,MAAM;gBACrB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC;YACvC;gBACE,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC;QAC1C,CAAC;IACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module HyperModeling\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { SectionType } from \"@itwin/core-common\";\r\nimport { IModelApp, IModelConnection, ScreenViewport, tryImageElementFromUrl, ViewManip } from \"@itwin/core-frontend\";\r\nimport { registerTools } from \"./Tools\";\r\nimport { HyperModelingDecorator } from \"./HyperModelingDecorator\";\r\nimport { HyperModelingConfig, SectionGraphicsConfig, SectionMarkerConfig } from \"./HyperModelingConfig\";\r\nimport { SectionMarkerHandler } from \"./SectionMarkerHandler\";\r\n\r\n/** @internal */\r\nexport interface MarkerData {\r\n readonly label: string;\r\n readonly image: HTMLImageElement | undefined;\r\n}\r\n\r\ninterface Resources {\r\n readonly namespace?: string;\r\n readonly markers: {\r\n readonly section: MarkerData;\r\n readonly plan: MarkerData;\r\n readonly elevation: MarkerData;\r\n readonly detail: MarkerData;\r\n };\r\n}\r\n\r\ninterface MaybeInitialized {\r\n resources?: Resources;\r\n}\r\n\r\ninterface Initialized {\r\n resources: Resources;\r\n}\r\n\r\nfunction assertInitialized(maybe: MaybeInitialized): asserts maybe is Initialized {\r\n if (undefined === maybe.resources)\r\n throw new Error(\"You must call HyperModeling.initialize before using the hypermodeling package\");\r\n}\r\n\r\n/** The API entry point for the hypermodeling package. Applications must call [[initialize]] and await the result before using the package.\r\n * The behavior of the package can be customized via a [[HyperModelingConfig]] supplied to [[initialize]], [[updateConfiguration]], or [[replaceConfiguration]].\r\n * Hypermodeling mode can be enabled or disabled via [[startOrStop]], which returns a [[HyperModelingDecorator]] when enabling hypermodeling.\r\n * Consult the package's `README.md` for a description of the available functionality.\r\n * @public\r\n */\r\nexport class HyperModeling {\r\n /** @internal */\r\n public static resources?: Resources;\r\n private static _markerHandler?: SectionMarkerHandler;\r\n private static _markerConfig: SectionMarkerConfig = {};\r\n private static _graphicsConfig: SectionGraphicsConfig = {};\r\n\r\n private static shutdown() {\r\n this.resources = undefined;\r\n this._markerHandler = undefined;\r\n this._markerConfig = {};\r\n this._graphicsConfig = {};\r\n }\r\n\r\n /** Returns whether the hypermodeling package is initialized.\r\n * @see [[HyperModeling.initialize]] to initialize the package.\r\n */\r\n public static get isInitialized(): boolean {\r\n return undefined !== this.resources;\r\n }\r\n\r\n /** Invoke this method to initialize the hypermodeling package for use. You *must* await the result before using any of this package's APIs.\r\n * Typically an application would invoke this after [IModelApp.startup]($frontend), e.g.,\r\n * ```ts\r\n * await IModelApp.startup();\r\n * await HyperModeling.initialize();\r\n * ```\r\n * Calling this method again after the first initialization behaves the same as calling [[HyperModeling.replaceConfiguration]].\r\n * @note The hypermodeling package will be reset to uninitialized after [IModelApp.shutdown]($frontend) is invoked.\r\n * @see [[replaceConfiguration]] and [[updateConfiguration]] to modify the configuration after initialization.\r\n */\r\n public static async initialize(config?: HyperModelingConfig): Promise<void> {\r\n if (undefined !== this.resources) {\r\n this.replaceConfiguration(config);\r\n return;\r\n }\r\n\r\n // clean up if we're being shut down\r\n IModelApp.onBeforeShutdown.addListener(() => this.shutdown());\r\n\r\n const namespace = \"HyperModeling\";\r\n await IModelApp.localization.registerNamespace(namespace);\r\n\r\n const loadImages = [\r\n tryImageElementFromUrl(`${IModelApp.publicPath}section-marker.svg`),\r\n tryImageElementFromUrl(`${IModelApp.publicPath}detail-marker.svg`),\r\n tryImageElementFromUrl(`${IModelApp.publicPath}elevation-marker.svg`),\r\n tryImageElementFromUrl(`${IModelApp.publicPath}plan-marker.svg`),\r\n ];\r\n\r\n const images = await Promise.all(loadImages);\r\n this.resources = {\r\n namespace,\r\n markers: {\r\n section: { image: images[0], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.SectionCallout\") },\r\n detail: { image: images[1], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.DetailCallout\") },\r\n elevation: { image: images[2], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.ElevationCallout\") },\r\n plan: { image: images[3], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.PlanCallout\") },\r\n },\r\n };\r\n\r\n registerTools(namespace);\r\n this.replaceConfiguration(config);\r\n }\r\n\r\n private static async ensureInitialized(): Promise<void> {\r\n if (undefined === this.resources)\r\n await this.initialize();\r\n\r\n assertInitialized(this);\r\n }\r\n\r\n /** Replaces the current package configuration, overwriting all previous settings. Passing `undefined` resets all settings to defaults.\r\n * @see [[HyperModeling.updateConfiguration]] for overriding specific aspects of the configuration.\r\n */\r\n public static replaceConfiguration(config?: HyperModelingConfig): void {\r\n config = config ?? {};\r\n this._markerHandler = config.markerHandler ?? new SectionMarkerHandler();\r\n this._markerConfig = config.markers ? { ...config.markers } : {};\r\n this._graphicsConfig = config.graphics ? { ...config.graphics } : {};\r\n }\r\n\r\n /** Overrides specific aspects of the current package configuration. Any field that is not `undefined` will be replaced in the current configuration;\r\n * the rest will retain their current values.\r\n * @see [[HyperModeling.replaceConfiguration]].\r\n */\r\n public static updateConfiguration(config: HyperModelingConfig): void {\r\n this._markerHandler = config.markerHandler ?? this._markerHandler;\r\n\r\n if (config.markers) {\r\n this._markerConfig = {\r\n ignoreModelSelector: config.markers.ignoreModelSelector ?? this._markerConfig.ignoreModelSelector,\r\n ignoreCategorySelector: config.markers.ignoreCategorySelector ?? this._markerConfig.ignoreCategorySelector,\r\n hiddenSectionTypes: config.markers.hiddenSectionTypes ?? this._markerConfig.hiddenSectionTypes,\r\n };\r\n }\r\n\r\n if (config.graphics) {\r\n this._graphicsConfig = {\r\n ignoreClip: config.graphics.ignoreClip ?? this._graphicsConfig.ignoreClip,\r\n debugClipVolumes: config.graphics.debugClipVolumes ?? this._graphicsConfig.debugClipVolumes,\r\n hideSectionGraphics: config.graphics.hideSectionGraphics ?? this._graphicsConfig.hideSectionGraphics,\r\n hideSheetAnnotations: config.graphics.hideSheetAnnotations ?? this._graphicsConfig.hideSheetAnnotations,\r\n };\r\n\r\n IModelApp.viewManager.invalidateViewportScenes();\r\n }\r\n }\r\n\r\n /** The handler that defines interactions with [[SectionMarker]]s.\r\n * @see [[initialize]] to override the default handler at package initialization.\r\n * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current handler.\r\n */\r\n public static get markerHandler(): SectionMarkerHandler {\r\n assertInitialized(this);\r\n assert(undefined !== this._markerHandler);\r\n return this._markerHandler;\r\n }\r\n\r\n /** The current marker display configuration applied to any newly-created [[HyperModelingDecorator]]s.\r\n * @see [[initialize]] to override the default configuration at package initialization.\r\n * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current configuration.\r\n * @see [[HyperModelingDecorator.replaceConfiguration]] or [[HyperModelingDecorator.updateConfiguration]] to change the configuration for an existing decorator.\r\n */\r\n public static get markerConfig(): SectionMarkerConfig {\r\n return this._markerConfig;\r\n }\r\n\r\n /** This graphics options applied to graphics displayed by all [[HyperModelingDecorator]]s.\r\n * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current configuration.\r\n */\r\n public static get graphicsConfig(): SectionGraphicsConfig {\r\n return this._graphicsConfig;\r\n }\r\n\r\n /** Returns true if the specified iModel contains any [SectionDrawingLocation]($backend)s. Hypermodeling is based on section drawing locations,\r\n * so if none are present, hypermodeling features are not relevant to the iModel. Attempting to use those features with such an iModel is fine,\r\n * but probably not useful.\r\n */\r\n public static async isSupportedForIModel(imodel: IModelConnection): Promise<boolean> {\r\n try {\r\n const reader = imodel.createQueryReader(\"SELECT ECInstanceId FROM bis.SectionDrawingLocation LIMIT 1\");\r\n return await reader.step(); // i.e., are any results are returned?\r\n } catch {\r\n // An iModel with a version of BisCore older than 1.0.11 will produce an expected \"table not found\" on the SectionDrawingLocation ECClass.\r\n return false;\r\n }\r\n }\r\n\r\n /** Returns whether hypermodeling is currently enabled for the specified viewport.\r\n * @see [[startOrStop]] to enable or disable hypermodeling for a viewport.\r\n */\r\n public static isEnabledForViewport(viewport: ScreenViewport): boolean {\r\n return undefined !== HyperModelingDecorator.getForViewport(viewport);\r\n }\r\n\r\n /** Start or stop hypermodeling mode for the specified viewport.\r\n * Enabling hypermodeling registers and returns a [[HyperModelingDecorator]] to display [[SectionMarker]]s within the viewport.\r\n * Disabling hypermodeling removes that decorator.\r\n * @param viewport The hypermodeling viewport\r\n * @param start `true` to enter hypermodeling mode, `false` to exit, or `undefined` to toggle the current mode.\r\n * @returns The new decorator is hypermodeling was successfully enabled.\r\n * @note Enabling hypermodeling may fail if the viewport is not viewing a spatial model or if the viewport's iModel does not support hypermodeling.\r\n * @see [[start]] and [[stop]].\r\n * @see [[isSupportedForIModel]].\r\n */\r\n public static async startOrStop(viewport: ScreenViewport, start?: boolean): Promise<HyperModelingDecorator | undefined> {\r\n // Help out the caller since we're async anyway...\r\n await this.ensureInitialized();\r\n\r\n const decorator = HyperModelingDecorator.getForViewport(viewport);\r\n if (undefined === start)\r\n start = undefined === decorator;\r\n\r\n if (start) {\r\n return this._start(viewport);\r\n } else {\r\n decorator?.[Symbol.dispose]();\r\n return undefined;\r\n }\r\n }\r\n\r\n /** Start hypermodeling mode for the specified viewport if it is not currently enabled.\r\n * If hypermodeling is already enabled for the viewport, the existing decorator is returned; otherwise, a new decorator is created.\r\n * @param viewport The viewport for which to enable hypermodeling\r\n * @returns The decorator that implements hypermodeling features for the viewport, or `undefined` if hypermodeling could not be enabled.\r\n * @note Enabling hypermodeling may fail if the viewport is not viewing a spatial model or if the viewport's iModel does not support hypermodeling.\r\n */\r\n public static async start(viewport: ScreenViewport): Promise<HyperModelingDecorator | undefined> {\r\n await this.ensureInitialized();\r\n return this._start(viewport);\r\n }\r\n\r\n private static async _start(viewport: ScreenViewport): Promise<HyperModelingDecorator | undefined> {\r\n assertInitialized(this);\r\n if (!viewport.view.isSpatialView())\r\n return undefined;\r\n\r\n let decorator = HyperModelingDecorator.getForViewport(viewport);\r\n if (!decorator)\r\n decorator = await HyperModelingDecorator.create(viewport, this._markerConfig);\r\n\r\n if (undefined !== decorator && viewport.view.isCameraOn) {\r\n // We want the 2d graphics to align with the 3d geometry. Perspective ruins that.\r\n viewport.view.turnCameraOff();\r\n ViewManip.fitView(viewport, false, { noSaveInUndo: true });\r\n viewport.clearViewUndo();\r\n }\r\n\r\n return decorator;\r\n }\r\n\r\n /** Stop hypermodeling mode for the specified viewport if it is currently enabled. This disposes of the [[HyperModelingDecorator]] associated with the viewport.\r\n * @see [[start]] to enable hypermodeling for a viewport.\r\n * @see [[startOrStop]] to toggle hypermodeling mode.\r\n */\r\n public static stop(viewport: ScreenViewport): void {\r\n const decorator = HyperModelingDecorator.getForViewport(viewport);\r\n decorator?.[Symbol.dispose]();\r\n }\r\n\r\n /** @internal */\r\n public static get namespace(): string | undefined {\r\n assertInitialized(this);\r\n return this.resources.namespace;\r\n }\r\n\r\n /** @internal */\r\n public static getMarkerData(type: SectionType): MarkerData {\r\n assertInitialized(this);\r\n switch (type) {\r\n case SectionType.Plan:\r\n return this.resources.markers.plan;\r\n case SectionType.Elevation:\r\n return this.resources.markers.elevation;\r\n case SectionType.Detail:\r\n return this.resources.markers.detail;\r\n default:\r\n return this.resources.markers.section;\r\n }\r\n }\r\n}\r\n"]}
@@ -64,7 +64,7 @@ export declare class HyperModelingDecorator implements Decorator {
64
64
  private toggleMarker;
65
65
  private dropTiledGraphicsProvider;
66
66
  /** @internal */
67
- dispose(): void;
67
+ [Symbol.dispose](): void;
68
68
  private showToolbarAfterTimeout;
69
69
  /** Toggles whether the clip volume associated with the specified marker is applied to the view. */
70
70
  toggleClipVolume(marker: SectionMarker, enable: boolean): void;
@@ -1 +1 @@
1
- {"version":3,"file":"HyperModelingDecorator.d.ts","sourceRoot":"","sources":["../../src/HyperModelingDecorator.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EACQ,eAAe,EAAE,SAAS,EAA+B,cAAc,EACrF,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAKnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAwC5D;;;;;;GAMG;AACH,qBAA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AM,CAAC,OAAO,CAAC,IAAI,IAAI;IAU/B,OAAO,CAAC,uBAAuB;IAO/B,mGAAmG;IAC5F,gBAAgB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;IAKrE;;;;;OAKG;IACU,aAAa,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAwBpF;;OAEG;IACU,gBAAgB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAUvF,wEAAwE;IACjE,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IAqB7C,0HAA0H;IAC7G,WAAW,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAQjE;;OAEG;IACU,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAa/D;;;;;OAKG;IACU,kBAAkB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAgBxE;;;;OAIG;IACU,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAUtE;;OAEG;IACI,WAAW,IAAI,IAAI;IAS1B,OAAO,CAAC,IAAI;IAQZ,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,sBAAsB;CAU/B"}
@@ -22,6 +22,10 @@ async function createMarkers(vp) {
22
22
  return new SectionMarkerSet(vp, markers);
23
23
  }
24
24
  class MarkerToolbarProvider {
25
+ _viewport;
26
+ marker;
27
+ toolbarProps;
28
+ onToolbarItemExecuted;
25
29
  constructor(marker, decorator) {
26
30
  this.marker = marker;
27
31
  this._viewport = decorator.viewport;
@@ -46,6 +50,18 @@ class MarkerToolbarProvider {
46
50
  * @public
47
51
  */
48
52
  export class HyperModelingDecorator {
53
+ /** The set of [[SectionMarker]]s controlled by this decorator. */
54
+ markers;
55
+ _config;
56
+ _removeEventListeners = new Array();
57
+ _iModel;
58
+ _needSync = false;
59
+ _toolbarProvider;
60
+ _tiledGraphicsProvider;
61
+ _activeMarker;
62
+ _appliedSpatialView;
63
+ /** @internal */
64
+ syncImmediately = false;
49
65
  /** Create a new decorator and register it with the [ViewManager]($frontend). Typically invoked indirectly via [[HyperModeling.startOrStop]]. */
50
66
  static async create(vp, config) {
51
67
  const markers = await createMarkers(vp);
@@ -120,17 +136,13 @@ export class HyperModelingDecorator {
120
136
  return true;
121
137
  }
122
138
  /** @internal */
139
+ useCachedDecorations = true;
140
+ /** @internal */
123
141
  decorate(context) {
124
142
  if (this.viewport.view.is3d())
125
143
  this.markers.addDecoration(context);
126
144
  }
127
145
  constructor(markers, config) {
128
- this._removeEventListeners = new Array();
129
- this._needSync = false;
130
- /** @internal */
131
- this.syncImmediately = false;
132
- /** @internal */
133
- this.useCachedDecorations = true;
134
146
  this.markers = markers;
135
147
  this._config = { ...config };
136
148
  this._iModel = this.viewport.iModel;
@@ -138,7 +150,7 @@ export class HyperModelingDecorator {
138
150
  this.requestSync();
139
151
  });
140
152
  this._removeEventListeners.push(this.viewport.onViewportChanged.addListener((_, changeFlags) => this.onViewportChanged(changeFlags)));
141
- this._removeEventListeners.push(this.viewport.onDisposed.addListener(() => this.dispose()));
153
+ this._removeEventListeners.push(this.viewport.onDisposed.addListener(() => this[Symbol.dispose]()));
142
154
  for (const marker of markers.markers) {
143
155
  marker.onMouseEnterEvent.addListener((mkr) => this.showToolbarAfterTimeout(mkr));
144
156
  marker.onMouseButtonEvent.addListener((mkr) => this.toggleMarker(mkr)); // eslint-disable-line @typescript-eslint/promise-function-async
@@ -148,7 +160,7 @@ export class HyperModelingDecorator {
148
160
  }
149
161
  onViewportChanged(changeFlags) {
150
162
  if (this.viewport.iModel !== this._iModel) {
151
- this.dispose();
163
+ this[Symbol.dispose]();
152
164
  return;
153
165
  }
154
166
  if (changeFlags.viewedCategories || changeFlags.viewedModels || changeFlags.viewedCategoriesPerModel)
@@ -171,7 +183,7 @@ export class HyperModelingDecorator {
171
183
  this._tiledGraphicsProvider = undefined;
172
184
  }
173
185
  /** @internal */
174
- dispose() {
186
+ [Symbol.dispose]() {
175
187
  if (!IModelApp.viewManager.dropDecorator(this))
176
188
  return;
177
189
  for (const remove of this._removeEventListeners)