@itwin/hypermodeling-frontend 5.0.0-dev.9 → 5.0.0-dev.92

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 (43) hide show
  1. package/CHANGELOG.md +51 -1
  2. package/lib/cjs/HyperModeling.js +7 -4
  3. package/lib/cjs/HyperModeling.js.map +1 -1
  4. package/lib/cjs/HyperModelingConfig.js.map +1 -1
  5. package/lib/cjs/HyperModelingDecorator.d.ts +1 -1
  6. package/lib/cjs/HyperModelingDecorator.d.ts.map +1 -1
  7. package/lib/cjs/HyperModelingDecorator.js +21 -9
  8. package/lib/cjs/HyperModelingDecorator.js.map +1 -1
  9. package/lib/cjs/PopupToolbar.js +13 -11
  10. package/lib/cjs/PopupToolbar.js.map +1 -1
  11. package/lib/cjs/SectionDrawingLocationState.js +57 -29
  12. package/lib/cjs/SectionDrawingLocationState.js.map +1 -1
  13. package/lib/cjs/SectionGraphicsProvider.d.ts.map +1 -1
  14. package/lib/cjs/SectionGraphicsProvider.js +14 -0
  15. package/lib/cjs/SectionGraphicsProvider.js.map +1 -1
  16. package/lib/cjs/SectionMarkerHandler.js.map +1 -1
  17. package/lib/cjs/SectionMarkers.js +11 -7
  18. package/lib/cjs/SectionMarkers.js.map +1 -1
  19. package/lib/cjs/Tools.js +4 -4
  20. package/lib/cjs/Tools.js.map +1 -1
  21. package/lib/cjs/hypermodeling-frontend.js.map +1 -1
  22. package/lib/esm/HyperModeling.js +7 -4
  23. package/lib/esm/HyperModeling.js.map +1 -1
  24. package/lib/esm/HyperModelingConfig.js.map +1 -1
  25. package/lib/esm/HyperModelingDecorator.d.ts +1 -1
  26. package/lib/esm/HyperModelingDecorator.d.ts.map +1 -1
  27. package/lib/esm/HyperModelingDecorator.js +21 -9
  28. package/lib/esm/HyperModelingDecorator.js.map +1 -1
  29. package/lib/esm/PopupToolbar.js +13 -11
  30. package/lib/esm/PopupToolbar.js.map +1 -1
  31. package/lib/esm/SectionDrawingLocationState.js +57 -29
  32. package/lib/esm/SectionDrawingLocationState.js.map +1 -1
  33. package/lib/esm/SectionGraphicsProvider.d.ts.map +1 -1
  34. package/lib/esm/SectionGraphicsProvider.js +14 -0
  35. package/lib/esm/SectionGraphicsProvider.js.map +1 -1
  36. package/lib/esm/SectionMarkerHandler.js.map +1 -1
  37. package/lib/esm/SectionMarkers.js +11 -7
  38. package/lib/esm/SectionMarkers.js.map +1 -1
  39. package/lib/esm/Tools.js +4 -4
  40. package/lib/esm/Tools.js.map +1 -1
  41. package/lib/esm/hypermodeling-frontend.js.map +1 -1
  42. package/lib/public/locales/en/HyperModeling.json +32 -32
  43. package/package.json +21 -21
@@ -1 +1 @@
1
- {"version":3,"file":"SectionDrawingLocationState.js","sourceRoot":"","sources":["../../src/SectionDrawingLocationState.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,oDAA8E;AAC9E,wDAA4G;AAC5G,wDAAuE;AAEvE,MAAM,uCAAuC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6B/C,CAAC;AA4CF;;;GAGG;AACH,MAAa,2BAA2B;IA8BtC,gBAAgB;IAChB,YAAmB,KAAsC,EAAE,MAAwB;QACjF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,iBAAiB,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,sBAAsB,CAAC;QAC1C,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;QACrC,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC;QACzC,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC;QACzC,IAAI,CAAC,yBAAyB,GAAG,yBAAS,CAAC,QA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D,MAAM,MAAM,GAAkC,EAAE,CAAC;QACjD,IAAI,CAAC;YACH,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,MAAM,CAAC,iBAAiB,CAAC,uCAAuC,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,4BAAc,CAAC,kBAAkB,EAAE,CAAC;gBACpJ,MAAM,CAAC,IAAI,CAAC,IAAI,2BAA2B,CAAC,GAAG,CAAC,KAAK,EAAqC,EAAE,MAAM,CAAC,CAAC,CAAC;QACzG,CAAC;QAAC,MAAM,CAAC;YACP,sKAAsK;QACxK,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA5HD,kEA4HC","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 { Id64String } from \"@itwin/core-bentley\";\r\nimport { Placement3d, QueryRowFormat, SectionType } from \"@itwin/core-common\";\r\nimport { DrawingViewState, IModelConnection, SheetViewState, SpatialViewState } from \"@itwin/core-frontend\";\r\nimport { ClipVector, Transform, XYZProps } from \"@itwin/core-geometry\";\r\n\r\nconst selectSectionDrawingLocationStatesECSql = `\r\n SELECT\r\n bis.SectionDrawingLocation.ECInstanceId as sectionLocationId,\r\n bis.SectionDrawingLocation.Model.Id as sectionLocationModelId,\r\n bis.SectionDrawingLocation.SectionView.Id as sectionViewId,\r\n bis.SectionDrawingLocation.Category.Id as categoryId,\r\n bis.SectionDrawingLocation.Origin as origin,\r\n bis.SectionDrawingLocation.Yaw as yaw,\r\n bis.SectionDrawingLocation.Pitch as pitch,\r\n bis.SectionDrawingLocation.Roll as roll,\r\n bis.SectionDrawingLocation.BBoxLow as bboxLow,\r\n bis.SectionDrawingLocation.BBoxHigh as bboxHigh,\r\n bis.SectionDrawingLocation.UserLabel as userLabel,\r\n\r\n bis.SectionDrawing.SectionType as sectionType,\r\n json_extract(bis.SectionDrawing.jsonProperties, '$.drawingToSpatialTransform') as drawingToSpatialTransform,\r\n bis.SectionDrawing.SpatialView.Id as spatialViewId,\r\n json_extract(bis.SectionDrawing.jsonProperties, '$.sheetToSpatialTransform') as sheetToSpatialTransform,\r\n json_extract(bis.SectionDrawing.jsonProperties, '$.drawingBoundaryClip') as sheetClip,\r\n\r\n json_extract(bis.SpatialViewDefinition.jsonProperties, '$.viewDetails.clip') as clipJSON,\r\n bis.ViewAttachment.ECInstanceId as viewAttachmentId,\r\n bis.SheetViewDefinition.ECInstanceId as sheetViewId\r\n FROM bis.SectionDrawingLocation\r\n INNER JOIN bis.ViewDefinition2d on bis.SectionDrawingLocation.SectionView.Id = bis.ViewDefinition2d.ECInstanceId\r\n INNER JOIN bis.SectionDrawing on bis.ViewDefinition2d.BaseModel.Id = bis.SectionDrawing.ECInstanceId\r\n LEFT JOIN bis.ViewAttachment on bis.ViewDefinition2d.ECInstanceId = bis.ViewAttachment.View.Id\r\n LEFT JOIN bis.SheetViewDefinition on bis.SheetViewDefinition.BaseModel.Id = bis.ViewAttachment.Model.Id\r\n INNER JOIN bis.SpatialViewDefinition on bis.SpatialViewDefinition.ECInstanceId = bis.SectionDrawing.SpatialView.Id\r\n`;\r\n\r\n/** Raw data representing a [[SectionDrawingLocationState]]. This is an amalgamation of data from several related ECClasses.\r\n * @internal\r\n */\r\nexport interface SectionDrawingLocationStateData {\r\n sectionType: SectionType;\r\n drawingToSpatialTransform: string; // stringified TransformProps\r\n spatialViewId: Id64String;\r\n clipJSON?: string; // stringified ClipVector json\r\n viewAttachmentId?: Id64String;\r\n sheetToSpatialTransform?: string; // stringified TransformProps\r\n sheetClip?: string; // stringified ClipVector json\r\n sheetViewId?: Id64String;\r\n\r\n sectionLocationId: Id64String;\r\n sectionLocationModelId: Id64String;\r\n sectionViewId: Id64String;\r\n categoryId: Id64String;\r\n origin?: XYZProps;\r\n yaw?: number;\r\n pitch?: number;\r\n roll?: number;\r\n bboxLow?: XYZProps;\r\n bboxHigh?: XYZProps;\r\n userLabel: string;\r\n}\r\n\r\n/** Represents a [ViewAttachment]($backend) that attaches a [[SectionDrawingLocationState]] to a [Sheet]($backend) model.\r\n * @public\r\n */\r\nexport interface SectionViewAttachment {\r\n /** The view attachment's element Id. */\r\n readonly id: Id64String;\r\n /** The Id of a [SheetViewDefinition]($backend) that displays this view attachment.\r\n * This is used when navigating from the spatial view to the view attachment.\r\n */\r\n readonly viewId?: Id64String;\r\n /** The transform from the [Sheet]($backend) coordinate space to the spatial coordinate space. */\r\n readonly transformToSpatial: Transform;\r\n /** Optional 2d clip vector used to clip out portions of the [Sheet]($backend) containing annotations not relevant to this section drawing. */\r\n readonly clip?: ClipVector;\r\n}\r\n\r\n/** Represents a [SectionDrawingLocation]($backend), including data from related elements like [SectionDrawing]($backend) used in a hyper-modeling context.\r\n * @see [[SectionMarker]] for a widget that allows the user to interact with a section drawing location.\r\n * @public\r\n */\r\nexport class SectionDrawingLocationState {\r\n /** The iModel in which this section drawing location resides. */\r\n public readonly iModel: IModelConnection;\r\n /** The element Id of the section drawing location. */\r\n public readonly id: Id64String;\r\n /** The Id of the [GeometricModel3d]($backend) in which this section drawing location resides. */\r\n public readonly model: Id64String;\r\n /** A user-friendly label for the section drawing location. */\r\n public readonly userLabel: string;\r\n /** The Id of the [SpatialCategory]($backend) to which this section drawing location belongs. */\r\n public readonly category: Id64String;\r\n /** The section drawing location's spatial placement. */\r\n public readonly placement: Placement3d;\r\n /** The type of section that generated the associated [SectionDrawing]($backend). */\r\n public readonly sectionType: SectionType;\r\n /** The Id of the [ViewDefinition]($backend) that can display the section graphics. */\r\n public readonly drawingViewId: Id64String;\r\n /** The Id of the [SpatialViewDefinition]($backend) from which the section drawing was generated. */\r\n public readonly spatialViewId: Id64String;\r\n /** The section clip from the [SpatialViewDefinition]($backend) from which the section drawing was generated. */\r\n public readonly clip: ClipVector;\r\n /** The transform from the [GeometricModel]($backend) containing the section graphics to the spatial coordinate space.\r\n * This is used to position the 2d graphics in the context of a spatial view.\r\n */\r\n public readonly drawingToSpatialTransform: Transform;\r\n /** If the section drawing is attached to a [Sheet]($backend), details about the corresponding [ViewAttachment]($backend).\r\n * When this section drawing location is displayed in a spatial context, annotations in the sheet model can be displayed along with the section graphics.\r\n */\r\n public readonly viewAttachment?: SectionViewAttachment;\r\n\r\n /** @internal */\r\n public constructor(props: SectionDrawingLocationStateData, iModel: IModelConnection) {\r\n this.iModel = iModel;\r\n this.id = props.sectionLocationId;\r\n this.model = props.sectionLocationModelId;\r\n this.userLabel = props.userLabel;\r\n this.category = props.categoryId;\r\n this.sectionType = props.sectionType;\r\n this.drawingViewId = props.sectionViewId;\r\n this.spatialViewId = props.spatialViewId;\r\n this.drawingToSpatialTransform = Transform.fromJSON(JSON.parse(props.drawingToSpatialTransform));\r\n\r\n const extractClip = (str: string | undefined) => {\r\n let clip;\r\n if (str) {\r\n try {\r\n clip = ClipVector.fromJSON(JSON.parse(str));\r\n } catch { }\r\n }\r\n\r\n return clip;\r\n };\r\n\r\n this.clip = extractClip(props.clipJSON) ?? ClipVector.createEmpty();\r\n\r\n const placementProps = {\r\n origin: props.origin ?? {},\r\n angles: {\r\n yaw: props.yaw,\r\n pitch: props.pitch,\r\n roll: props.roll,\r\n },\r\n placement: (props.bboxLow && props.bboxHigh) ? { low: props.bboxLow, high: props.bboxHigh } : undefined,\r\n };\r\n this.placement = Placement3d.fromJSON(placementProps);\r\n\r\n if (props.viewAttachmentId && props.sheetToSpatialTransform) {\r\n this.viewAttachment = {\r\n id: props.viewAttachmentId,\r\n transformToSpatial: Transform.fromJSON(JSON.parse(props.sheetToSpatialTransform)),\r\n clip: extractClip(props.sheetClip),\r\n viewId: props.sheetViewId,\r\n };\r\n }\r\n }\r\n\r\n /** Return a promise that resolves to the [DrawingViewState]($frontend) corresponding to `this.drawingViewId`, or undefined if an exception occurs. */\r\n public async tryLoadDrawingView(): Promise<DrawingViewState | undefined> {\r\n try {\r\n const view = await this.iModel.views.load(this.drawingViewId);\r\n if (view instanceof DrawingViewState)\r\n return view;\r\n } catch { }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Return a promise that resolves to the [SpatialViewState]($frontend) corresponding to `this.spatialViewId`, or undefined if an exception occurs. */\r\n public async tryLoadSpatialView(): Promise<SpatialViewState | undefined> {\r\n try {\r\n const view = await this.iModel.views.load(this.spatialViewId);\r\n if (view instanceof SpatialViewState)\r\n return view;\r\n } catch { }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Return a promise that resolves to the [SheetViewState]($frontend) corresponding to `this.viewAttachment.viewId`; or undefined if there is no corresponding [ViewAttachment]($backend) or an exception occurs. */\r\n public async tryLoadSheetView(): Promise<SheetViewState | undefined> {\r\n if (undefined === this.viewAttachment || undefined === this.viewAttachment.viewId)\r\n return undefined;\r\n\r\n try {\r\n const view = await this.iModel.views.load(this.viewAttachment.viewId);\r\n if (view instanceof SheetViewState)\r\n return view;\r\n } catch { }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Query the specified iModel for [SectionDrawingLocation]($backend)s and return a list of corresponding [[SectionDrawingLocationState]]s. */\r\n public static async queryAll(iModel: IModelConnection): Promise<SectionDrawingLocationState[]> {\r\n const states: SectionDrawingLocationState[] = [];\r\n try {\r\n for await (const row of iModel.createQueryReader(selectSectionDrawingLocationStatesECSql, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }))\r\n states.push(new SectionDrawingLocationState(row.toRow() as SectionDrawingLocationStateData, iModel));\r\n } catch {\r\n // If the iModel contains a version of BisCore schema older than 1.12.0, the query will produce an exception due to missing SectionDrawingLocation class. That's fine.\r\n }\r\n\r\n return states;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SectionDrawingLocationState.js","sourceRoot":"","sources":["../../src/SectionDrawingLocationState.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,oDAA8E;AAC9E,wDAA4G;AAC5G,wDAAuE;AAEvE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MAAM,CAAC,IAAI,CAAC,IAAI,2BAA2B,CAAC,GAAG,CAAC,KAAK,EAAqC,EAAE,MAAM,CAAC,CAAC,CAAC;QACzG,CAAC;QAAC,MAAM,CAAC;YACP,sKAAsK;QACxK,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA5HD,kEA4HC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module HyperModeling\n */\n\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { Placement3d, QueryRowFormat, SectionType } from \"@itwin/core-common\";\nimport { DrawingViewState, IModelConnection, SheetViewState, SpatialViewState } from \"@itwin/core-frontend\";\nimport { ClipVector, Transform, XYZProps } from \"@itwin/core-geometry\";\n\nconst selectSectionDrawingLocationStatesECSql = `\n SELECT\n bis.SectionDrawingLocation.ECInstanceId as sectionLocationId,\n bis.SectionDrawingLocation.Model.Id as sectionLocationModelId,\n bis.SectionDrawingLocation.SectionView.Id as sectionViewId,\n bis.SectionDrawingLocation.Category.Id as categoryId,\n bis.SectionDrawingLocation.Origin as origin,\n bis.SectionDrawingLocation.Yaw as yaw,\n bis.SectionDrawingLocation.Pitch as pitch,\n bis.SectionDrawingLocation.Roll as roll,\n bis.SectionDrawingLocation.BBoxLow as bboxLow,\n bis.SectionDrawingLocation.BBoxHigh as bboxHigh,\n bis.SectionDrawingLocation.UserLabel as userLabel,\n\n bis.SectionDrawing.SectionType as sectionType,\n json_extract(bis.SectionDrawing.jsonProperties, '$.drawingToSpatialTransform') as drawingToSpatialTransform,\n bis.SectionDrawing.SpatialView.Id as spatialViewId,\n json_extract(bis.SectionDrawing.jsonProperties, '$.sheetToSpatialTransform') as sheetToSpatialTransform,\n json_extract(bis.SectionDrawing.jsonProperties, '$.drawingBoundaryClip') as sheetClip,\n\n json_extract(bis.SpatialViewDefinition.jsonProperties, '$.viewDetails.clip') as clipJSON,\n bis.ViewAttachment.ECInstanceId as viewAttachmentId,\n bis.SheetViewDefinition.ECInstanceId as sheetViewId\n FROM bis.SectionDrawingLocation\n INNER JOIN bis.ViewDefinition2d on bis.SectionDrawingLocation.SectionView.Id = bis.ViewDefinition2d.ECInstanceId\n INNER JOIN bis.SectionDrawing on bis.ViewDefinition2d.BaseModel.Id = bis.SectionDrawing.ECInstanceId\n LEFT JOIN bis.ViewAttachment on bis.ViewDefinition2d.ECInstanceId = bis.ViewAttachment.View.Id\n LEFT JOIN bis.SheetViewDefinition on bis.SheetViewDefinition.BaseModel.Id = bis.ViewAttachment.Model.Id\n INNER JOIN bis.SpatialViewDefinition on bis.SpatialViewDefinition.ECInstanceId = bis.SectionDrawing.SpatialView.Id\n`;\n\n/** Raw data representing a [[SectionDrawingLocationState]]. This is an amalgamation of data from several related ECClasses.\n * @internal\n */\nexport interface SectionDrawingLocationStateData {\n sectionType: SectionType;\n drawingToSpatialTransform: string; // stringified TransformProps\n spatialViewId: Id64String;\n clipJSON?: string; // stringified ClipVector json\n viewAttachmentId?: Id64String;\n sheetToSpatialTransform?: string; // stringified TransformProps\n sheetClip?: string; // stringified ClipVector json\n sheetViewId?: Id64String;\n\n sectionLocationId: Id64String;\n sectionLocationModelId: Id64String;\n sectionViewId: Id64String;\n categoryId: Id64String;\n origin?: XYZProps;\n yaw?: number;\n pitch?: number;\n roll?: number;\n bboxLow?: XYZProps;\n bboxHigh?: XYZProps;\n userLabel: string;\n}\n\n/** Represents a [ViewAttachment]($backend) that attaches a [[SectionDrawingLocationState]] to a [Sheet]($backend) model.\n * @public\n */\nexport interface SectionViewAttachment {\n /** The view attachment's element Id. */\n readonly id: Id64String;\n /** The Id of a [SheetViewDefinition]($backend) that displays this view attachment.\n * This is used when navigating from the spatial view to the view attachment.\n */\n readonly viewId?: Id64String;\n /** The transform from the [Sheet]($backend) coordinate space to the spatial coordinate space. */\n readonly transformToSpatial: Transform;\n /** Optional 2d clip vector used to clip out portions of the [Sheet]($backend) containing annotations not relevant to this section drawing. */\n readonly clip?: ClipVector;\n}\n\n/** Represents a [SectionDrawingLocation]($backend), including data from related elements like [SectionDrawing]($backend) used in a hyper-modeling context.\n * @see [[SectionMarker]] for a widget that allows the user to interact with a section drawing location.\n * @public\n */\nexport class SectionDrawingLocationState {\n /** The iModel in which this section drawing location resides. */\n public readonly iModel: IModelConnection;\n /** The element Id of the section drawing location. */\n public readonly id: Id64String;\n /** The Id of the [GeometricModel3d]($backend) in which this section drawing location resides. */\n public readonly model: Id64String;\n /** A user-friendly label for the section drawing location. */\n public readonly userLabel: string;\n /** The Id of the [SpatialCategory]($backend) to which this section drawing location belongs. */\n public readonly category: Id64String;\n /** The section drawing location's spatial placement. */\n public readonly placement: Placement3d;\n /** The type of section that generated the associated [SectionDrawing]($backend). */\n public readonly sectionType: SectionType;\n /** The Id of the [ViewDefinition]($backend) that can display the section graphics. */\n public readonly drawingViewId: Id64String;\n /** The Id of the [SpatialViewDefinition]($backend) from which the section drawing was generated. */\n public readonly spatialViewId: Id64String;\n /** The section clip from the [SpatialViewDefinition]($backend) from which the section drawing was generated. */\n public readonly clip: ClipVector;\n /** The transform from the [GeometricModel]($backend) containing the section graphics to the spatial coordinate space.\n * This is used to position the 2d graphics in the context of a spatial view.\n */\n public readonly drawingToSpatialTransform: Transform;\n /** If the section drawing is attached to a [Sheet]($backend), details about the corresponding [ViewAttachment]($backend).\n * When this section drawing location is displayed in a spatial context, annotations in the sheet model can be displayed along with the section graphics.\n */\n public readonly viewAttachment?: SectionViewAttachment;\n\n /** @internal */\n public constructor(props: SectionDrawingLocationStateData, iModel: IModelConnection) {\n this.iModel = iModel;\n this.id = props.sectionLocationId;\n this.model = props.sectionLocationModelId;\n this.userLabel = props.userLabel;\n this.category = props.categoryId;\n this.sectionType = props.sectionType;\n this.drawingViewId = props.sectionViewId;\n this.spatialViewId = props.spatialViewId;\n this.drawingToSpatialTransform = Transform.fromJSON(JSON.parse(props.drawingToSpatialTransform));\n\n const extractClip = (str: string | undefined) => {\n let clip;\n if (str) {\n try {\n clip = ClipVector.fromJSON(JSON.parse(str));\n } catch { }\n }\n\n return clip;\n };\n\n this.clip = extractClip(props.clipJSON) ?? ClipVector.createEmpty();\n\n const placementProps = {\n origin: props.origin ?? {},\n angles: {\n yaw: props.yaw,\n pitch: props.pitch,\n roll: props.roll,\n },\n placement: (props.bboxLow && props.bboxHigh) ? { low: props.bboxLow, high: props.bboxHigh } : undefined,\n };\n this.placement = Placement3d.fromJSON(placementProps);\n\n if (props.viewAttachmentId && props.sheetToSpatialTransform) {\n this.viewAttachment = {\n id: props.viewAttachmentId,\n transformToSpatial: Transform.fromJSON(JSON.parse(props.sheetToSpatialTransform)),\n clip: extractClip(props.sheetClip),\n viewId: props.sheetViewId,\n };\n }\n }\n\n /** Return a promise that resolves to the [DrawingViewState]($frontend) corresponding to `this.drawingViewId`, or undefined if an exception occurs. */\n public async tryLoadDrawingView(): Promise<DrawingViewState | undefined> {\n try {\n const view = await this.iModel.views.load(this.drawingViewId);\n if (view instanceof DrawingViewState)\n return view;\n } catch { }\n\n return undefined;\n }\n\n /** Return a promise that resolves to the [SpatialViewState]($frontend) corresponding to `this.spatialViewId`, or undefined if an exception occurs. */\n public async tryLoadSpatialView(): Promise<SpatialViewState | undefined> {\n try {\n const view = await this.iModel.views.load(this.spatialViewId);\n if (view instanceof SpatialViewState)\n return view;\n } catch { }\n\n return undefined;\n }\n\n /** Return a promise that resolves to the [SheetViewState]($frontend) corresponding to `this.viewAttachment.viewId`; or undefined if there is no corresponding [ViewAttachment]($backend) or an exception occurs. */\n public async tryLoadSheetView(): Promise<SheetViewState | undefined> {\n if (undefined === this.viewAttachment || undefined === this.viewAttachment.viewId)\n return undefined;\n\n try {\n const view = await this.iModel.views.load(this.viewAttachment.viewId);\n if (view instanceof SheetViewState)\n return view;\n } catch { }\n\n return undefined;\n }\n\n /** Query the specified iModel for [SectionDrawingLocation]($backend)s and return a list of corresponding [[SectionDrawingLocationState]]s. */\n public static async queryAll(iModel: IModelConnection): Promise<SectionDrawingLocationState[]> {\n const states: SectionDrawingLocationState[] = [];\n try {\n for await (const row of iModel.createQueryReader(selectSectionDrawingLocationStatesECSql, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }))\n states.push(new SectionDrawingLocationState(row.toRow() as SectionDrawingLocationStateData, iModel));\n } catch {\n // If the iModel contains a version of BisCore schema older than 1.12.0, the query will produce an exception due to missing SectionDrawingLocation class. That's fine.\n }\n\n return states;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SectionGraphicsProvider.d.ts","sourceRoot":"","sources":["../../src/SectionGraphicsProvider.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAE+J,qBAAqB,EAE1L,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AA+T5E;;;;;;GAMG;AACH,wBAAsB,6BAA6B,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAStH"}
1
+ {"version":3,"file":"SectionGraphicsProvider.d.ts","sourceRoot":"","sources":["../../src/SectionGraphicsProvider.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAE+J,qBAAqB,EAE1L,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAsU5E;;;;;;GAMG;AACH,wBAAsB,6BAA6B,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAStH"}
@@ -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":"SectionGraphicsProvider.js","sourceRoot":"","sources":["../../src/SectionGraphicsProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAgVH,sEASC;AAvVD,sDAAoF;AACpF,wDAA0F;AAC1F,oDAA0H;AAC1H,wDAI8B;AAE9B,mDAAgD;AAgBhD,MAAM,iBAAiB;IACd,kBAAkB,CAAC,GAAgB,EAAE,GAAgB;QAC1D,IAAI,GAAG,GAAG,IAAA,8BAAe,EAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QACpD,IAAI,CAAC,KAAK,GAAG;YACX,GAA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AAC,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QACjF,IAAI,UAAU;YACZ,IAAI,CAAC,SAAS,GAAG,IAAI,kBAAkB,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAClF,CAAC;IAEM,kBAAkB,CAAC,SAAmB,EAAE,IAAsC;QACnF,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACvB,IAAI,SAAS,KAAK,IAAI,CAAC,SAAS;YAC9B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACzB,CAAC;CACF;AAED;;;;;;GAMG;AACI,KAAK,UAAU,6BAA6B,CAAC,KAAkC;IACpF,IAAI,UAAU,CAAC;IACf,IAAI,SAAS,KAAK,KAAK,CAAC,cAAc,EAAE,CAAC;QACvC,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE,CAA0B,CAAC;QAC3G,IAAI,CAAC,KAAK,WAAW,CAAC,MAAM;YAC1B,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,IAAI,uBAAuB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;AACxD,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, compareBooleans, compareStrings, Id64 } from \"@itwin/core-bentley\";\r\nimport { ClipShape, ClipVector, Point3d, Range3d, Transform } from \"@itwin/core-geometry\";\r\nimport { ColorDef, Placement2d, ViewAttachmentProps, ViewDefinition2dProps, ViewFlagOverrides } from \"@itwin/core-common\";\r\nimport {\r\n CategorySelectorState, DisclosedTileTreeSet, DisplayStyle2dState, DrawingViewState,\r\n FeatureSymbology, GeometricModel2dState, GraphicBranch, HitDetail, IModelApp, IModelConnection, RenderClipVolume, RenderSystem, SheetModelState, Tile, TileContent, TiledGraphicsProvider, TileDrawArgs,\r\n TileLoadPriority, TileRequest, TileRequestChannel, TileTree, TileTreeOwner, TileTreeReference, TileTreeSupplier, Viewport, ViewState2d,\r\n} from \"@itwin/core-frontend\";\r\nimport { SectionDrawingLocationState } from \"./SectionDrawingLocationState\";\r\nimport { HyperModeling } from \"./HyperModeling\";\r\n\r\ninterface ProxyTreeId {\r\n state: SectionDrawingLocationState;\r\n isSheet: boolean;\r\n attachment?: ViewAttachmentProps;\r\n}\r\n\r\ninterface ProxyTreeParams {\r\n tree: TileTree;\r\n ref: TileTreeReference;\r\n view: ViewState2d;\r\n state: SectionDrawingLocationState;\r\n attachment?: ViewAttachmentProps;\r\n}\r\n\r\nclass ProxyTreeSupplier implements TileTreeSupplier {\r\n public compareTileTreeIds(lhs: ProxyTreeId, rhs: ProxyTreeId): number {\r\n let cmp = compareBooleans(lhs.isSheet, rhs.isSheet);\r\n if (0 === cmp)\r\n cmp = compareStrings(lhs.state.id, rhs.state.id);\r\n\r\n return cmp;\r\n }\r\n\r\n public async createTileTree(id: ProxyTreeId, iModel: IModelConnection): Promise<TileTree | undefined> {\r\n let view;\r\n if (id.isSheet) {\r\n assert(undefined !== id.attachment);\r\n view = await this.createSheetViewState(id.state, id.attachment);\r\n } else {\r\n view = await id.state.tryLoadDrawingView();\r\n }\r\n\r\n if (undefined === view)\r\n return undefined;\r\n\r\n try {\r\n await iModel.models.load(view.baseModelId);\r\n const model = iModel.models.getLoaded(view.baseModelId);\r\n if (undefined === model || !(model instanceof GeometricModel2dState))\r\n return undefined;\r\n\r\n const treeRef = model.createTileTreeReference(view);\r\n const tree = await treeRef.treeOwner.loadTree();\r\n if (undefined === tree)\r\n return undefined;\r\n\r\n const ctor = id.isSheet ? SheetProxyTree : DrawingProxyTree;\r\n return new ctor({ tree, ref: treeRef, view, state: id.state, attachment: id.attachment });\r\n } catch {\r\n return undefined;\r\n }\r\n }\r\n\r\n private async createSheetViewState(state: SectionDrawingLocationState, attachment: ViewAttachmentProps): Promise<DrawingViewState | undefined> {\r\n assert(undefined !== state.viewAttachment);\r\n try {\r\n // A persistent view of the sheet doesn't necessarily exist, and we don't want a SheetViewState anyway.\r\n // All we want is to draw all the elements in the sheet (sans view attachments) clipped by the drawing boundary.\r\n // However, ModelState.createTileTreeReference() requires a ViewState.\r\n await state.iModel.models.load(attachment.model);\r\n const sheet = state.iModel.models.getLoaded(attachment.model);\r\n if (undefined === sheet || !(sheet instanceof SheetModelState))\r\n return undefined;\r\n\r\n const sheetExtents = await sheet.queryModelRange();\r\n const viewProps: ViewDefinition2dProps = {\r\n baseModelId: attachment.model,\r\n origin: { x: 0, y: 0 },\r\n delta: { x: sheetExtents.high.x, y: sheetExtents.high.y },\r\n angle: 0,\r\n categorySelectorId: Id64.invalid,\r\n displayStyleId: Id64.invalid,\r\n model: Id64.invalid,\r\n code: {\r\n spec: Id64.invalid,\r\n scope: Id64.invalid,\r\n },\r\n classFullName: DrawingViewState.classFullName,\r\n };\r\n\r\n const displayStyle = new DisplayStyle2dState({} as any, state.iModel);\r\n const categorySelector = new CategorySelectorState({} as any, state.iModel);\r\n\r\n return new DrawingViewState(viewProps, state.iModel, categorySelector, displayStyle, sheetExtents);\r\n } catch {\r\n return undefined;\r\n }\r\n }\r\n}\r\n\r\nconst proxyTreeSupplier = new ProxyTreeSupplier();\r\n\r\n/** A proxy for a 2d tile tree to be drawn in the context of a spatial view. */\r\nclass ProxyTreeReference extends TileTreeReference {\r\n private readonly _owner: TileTreeOwner;\r\n\r\n public constructor(id: ProxyTreeId) {\r\n super();\r\n this._owner = id.state.iModel.tiles.getTileTreeOwner(id, proxyTreeSupplier);\r\n }\r\n\r\n public override get castsShadows() {\r\n return false;\r\n }\r\n\r\n public override getClipVolume(tree: TileTree) {\r\n return true !== HyperModeling.graphicsConfig.ignoreClip ? super.getClipVolume(tree) : undefined;\r\n }\r\n\r\n public get treeOwner() { return this._owner; }\r\n\r\n private get _proxiedRef(): TileTreeReference | undefined {\r\n const proxiedTree = this.treeOwner.tileTree as ProxyTree;\r\n return undefined !== proxiedTree ? proxiedTree.ref : undefined;\r\n }\r\n\r\n public override discloseTileTrees(trees: DisclosedTileTreeSet): void {\r\n super.discloseTileTrees(trees);\r\n const ref = this._proxiedRef;\r\n if (undefined !== ref)\r\n ref.discloseTileTrees(trees);\r\n }\r\n\r\n public override async getToolTip(hit: HitDetail) {\r\n const ref = this._proxiedRef;\r\n return undefined !== ref ? ref.getToolTip(hit) : super.getToolTip(hit);\r\n }\r\n}\r\n\r\n/** A proxy for a 2d tile tree to be drawn in the context of a spatial view. */\r\nabstract class ProxyTree extends TileTree {\r\n private readonly _rootTile: ProxyTile;\r\n private readonly _viewFlagOverrides: ViewFlagOverrides;\r\n public readonly tree: TileTree;\r\n public readonly ref: TileTreeReference;\r\n public readonly symbologyOverrides: FeatureSymbology.Overrides;\r\n\r\n protected constructor(params: ProxyTreeParams, location: Transform, clipVolume: RenderClipVolume | undefined) {\r\n const { tree, ref, view } = { ...params };\r\n super({\r\n id: params.state.id,\r\n modelId: tree.modelId,\r\n iModel: tree.iModel,\r\n location,\r\n priority: TileLoadPriority.Primary,\r\n clipVolume,\r\n });\r\n\r\n this.tree = tree;\r\n this.ref = ref;\r\n this.symbologyOverrides = new FeatureSymbology.Overrides(view);\r\n\r\n const range = tree.iModelTransform.multiplyRange(tree.rootTile.range);\r\n const inverse = location.inverse();\r\n if (undefined !== inverse)\r\n inverse.multiplyRange(range, range);\r\n\r\n this._viewFlagOverrides = {\r\n ...view.viewFlags,\r\n lighting: false,\r\n // View clip (section clip) should not apply to 2d graphics.\r\n clipVolume: false,\r\n };\r\n\r\n this._rootTile = new ProxyTile(this, range);\r\n }\r\n\r\n public get rootTile(): ProxyTile { return this._rootTile; }\r\n public get viewFlagOverrides() { return this._viewFlagOverrides; }\r\n public get is3d() { return false; }\r\n public override get isContentUnbounded() { return false; }\r\n public get maxDepth() { return 1; }\r\n\r\n protected abstract get isDisplayed(): boolean;\r\n\r\n public draw(args: TileDrawArgs): void {\r\n if (!this.isDisplayed)\r\n return;\r\n\r\n const tiles = this.selectTiles(args);\r\n for (const tile of tiles)\r\n tile.drawGraphics(args);\r\n\r\n args.drawGraphics();\r\n }\r\n\r\n protected _selectTiles(_args: TileDrawArgs): Tile[] {\r\n return this.isDisplayed ? [this.rootTile] : [];\r\n }\r\n\r\n public prune(): void {\r\n // Our single tile is only a proxy. Our proxied tree(s) will be pruned separately\r\n }\r\n}\r\n\r\nclass DrawingProxyTree extends ProxyTree {\r\n public constructor(params: ProxyTreeParams) {\r\n const { state, attachment } = { ...params };\r\n const location = state.drawingToSpatialTransform.clone();\r\n\r\n let clipVolume;\r\n if (attachment) {\r\n assert(undefined !== state.viewAttachment);\r\n const clipJSON = attachment.jsonProperties?.clip;\r\n const clip = clipJSON ? ClipVector.fromJSON(clipJSON) : ClipVector.createEmpty();\r\n if (!clipJSON) {\r\n const placement = Placement2d.fromJSON(attachment.placement);\r\n const range = placement.calculateRange();\r\n clip.appendShape([\r\n Point3d.create(range.low.x, range.low.y),\r\n Point3d.create(range.high.x, range.low.y),\r\n Point3d.create(range.high.x, range.high.y),\r\n Point3d.create(range.low.x, range.high.y),\r\n ]);\r\n }\r\n\r\n if (clip.isValid) {\r\n const sheetToWorld = state.viewAttachment.transformToSpatial.clone();\r\n clip.transformInPlace(sheetToWorld);\r\n clipVolume = IModelApp.renderSystem.createClipVolume(clip);\r\n }\r\n }\r\n\r\n super(params, location, clipVolume);\r\n }\r\n\r\n protected get isDisplayed() { return true !== HyperModeling.graphicsConfig.hideSectionGraphics; }\r\n}\r\n\r\nclass SheetProxyTree extends ProxyTree {\r\n public constructor(params: ProxyTreeParams) {\r\n const { state, attachment } = { ...params };\r\n assert(undefined !== state.viewAttachment);\r\n assert(undefined !== attachment);\r\n const location = state.viewAttachment.transformToSpatial.clone();\r\n\r\n let clipVolume;\r\n if (state.viewAttachment.clip)\r\n clipVolume = IModelApp.renderSystem.createClipVolume(state.viewAttachment.clip);\r\n\r\n super(params, location, clipVolume);\r\n\r\n // Our view is manufactured. It draws everything regardless of subcategory.\r\n this.symbologyOverrides.ignoreSubCategory = true;\r\n }\r\n\r\n protected get isDisplayed() { return true !== HyperModeling.graphicsConfig.hideSheetAnnotations; }\r\n}\r\n\r\n/** The single Tile belonging to a ProxyTree, serving as a proxy for all of the proxied tree's tiles. */\r\nclass ProxyTile extends Tile {\r\n public constructor(tree: ProxyTree, range: Range3d) {\r\n super({ contentId: \"\", range, maximumSize: 512, isLeaf: true }, tree);\r\n this.setIsReady();\r\n }\r\n\r\n public get hasChildren() { return false; }\r\n public override get hasGraphics() { return true; }\r\n\r\n public get channel(): TileRequestChannel { throw new Error(\"Proxy tile has no content\"); }\r\n public async requestContent(_isCanceled: () => boolean): Promise<TileRequest.Response> { return undefined; }\r\n public async readContent(_data: TileRequest.ResponseData, _system: RenderSystem, _isCanceled?: () => boolean): Promise<TileContent> { return {}; }\r\n protected _loadChildren(_resolve: (children: Tile[]) => void, _reject: (error: Error) => void): void { }\r\n\r\n public override drawGraphics(args: TileDrawArgs) {\r\n const proxyTree = this.tree as ProxyTree;\r\n const sectionTree = proxyTree.tree;\r\n\r\n const location = proxyTree.iModelTransform.multiplyTransformTransform(sectionTree.iModelTransform);\r\n const clipVolume = true === proxyTree.viewFlagOverrides.clipVolume ? proxyTree.clipVolume : undefined;\r\n args = new TileDrawArgs({ context: args.context, location, tree: sectionTree, now: args.now, viewFlagOverrides: proxyTree.viewFlagOverrides, clipVolume, parentsAndChildrenExclusive: args.parentsAndChildrenExclusive, symbologyOverrides: proxyTree.symbologyOverrides });\r\n sectionTree.draw(args);\r\n\r\n const rangeGfx = this.getRangeGraphic(args.context);\r\n if (undefined !== rangeGfx)\r\n args.graphics.add(rangeGfx);\r\n\r\n if (true !== HyperModeling.graphicsConfig.debugClipVolumes || undefined === proxyTree.clipVolume)\r\n return;\r\n\r\n const builder = args.context.createSceneGraphicBuilder();\r\n builder.setSymbology(ColorDef.red, ColorDef.red, 2);\r\n for (const prim of proxyTree.clipVolume.clipVector.clips) {\r\n if (!(prim instanceof ClipShape))\r\n continue;\r\n\r\n const tf = prim.transformFromClip;\r\n const pts = prim.polygon.map((pt) => tf ? tf.multiplyPoint3d(pt) : pt.clone());\r\n builder.addLineString(pts);\r\n }\r\n\r\n const branch = new GraphicBranch();\r\n branch.entries.push(builder.finish());\r\n branch.setViewFlagOverrides({ clipVolume: false });\r\n args.context.outputGraphic(args.context.createGraphicBranch(branch, Transform.createIdentity()));\r\n }\r\n}\r\n\r\n/** Draws the 2d section graphics into the 3d view. */\r\nclass SectionGraphicsProvider implements TiledGraphicsProvider {\r\n private readonly _drawingRef: TileTreeReference;\r\n private readonly _sheetRef?: TileTreeReference;\r\n\r\n public constructor(state: SectionDrawingLocationState, attachment: ViewAttachmentProps | undefined) {\r\n this._drawingRef = new ProxyTreeReference({ state, attachment, isSheet: false });\r\n if (attachment)\r\n this._sheetRef = new ProxyTreeReference({ state, attachment, isSheet: true });\r\n }\r\n\r\n public forEachTileTreeRef(_viewport: Viewport, func: (ref: TileTreeReference) => void): void {\r\n func(this._drawingRef);\r\n if (undefined !== this._sheetRef)\r\n func(this._sheetRef);\r\n }\r\n}\r\n\r\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).\r\n * Typically used indirectly via [[HyperModelingDecorator]].\r\n * @param state The section drawing location specifying which section drawing to display.\r\n * @returns A provider suitable for passing to [Viewport.addTiledGraphicsProvider]($frontend).\r\n * @see [[HyperModelingDecorator.toggleAttachment]] to activate section graphics for a given [[SectionMarker]].\r\n * @public\r\n */\r\nexport async function createSectionGraphicsProvider(state: SectionDrawingLocationState): Promise<TiledGraphicsProvider> {\r\n let attachment;\r\n if (undefined !== state.viewAttachment) {\r\n const attachments = await state.iModel.elements.getProps(state.viewAttachment.id) as ViewAttachmentProps[];\r\n if (1 === attachments.length)\r\n attachment = attachments[0];\r\n }\r\n\r\n return new SectionGraphicsProvider(state, attachment);\r\n}\r\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,GAAG,IAAA,8BAAe,EAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QACpD,IAAI,CAAC,KAAK,GAAG;YACX,GAAG,GAAG,IAAA,6BAAc,EAAC,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAEnD,OAAO,GAAG,CAAC;IACb,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,EAAe,EAAE,MAAwB;QACnE,IAAI,IAAI,CAAC;QACT,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;YACf,IAAA,qBAAM,EAAC,SAAS,KAAK,EAAE,CAAC,UAAU,CAAC,CAAC;YACpC,IAAI,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC;QAClE,CAAC;aAAM,CAAC;YACN,IAAI,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,kBAAkB,EAAE,CAAC;QAC7C,CAAC;QAED,IAAI,SAAS,KAAK,IAAI;YACpB,OAAO,SAAS,CAAC;QAEnB,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CA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AC;YACnB,MAAM,IAAI,CAAC,SAAS,CAAC;QACvB,CAAC;IACH,CAAC;CACF;AAED;;;;;;GAMG;AACI,KAAK,UAAU,6BAA6B,CAAC,KAAkC;IACpF,IAAI,UAAU,CAAC;IACf,IAAI,SAAS,KAAK,KAAK,CAAC,cAAc,EAAE,CAAC;QACvC,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE,CAA0B,CAAC;QAC3G,IAAI,CAAC,KAAK,WAAW,CAAC,MAAM;YAC1B,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,IAAI,uBAAuB,CAAC,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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SectionMarkerHandler.js","sourceRoot":"","sources":["../../src/SectionMarkerHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAAiD;AAMjD;;;;;;;;;;GAUG;AACH,MAAa,oBAAoB;IAC/B;;OAEG;IACI,KAAK,CAAC,cAAc,CAAC,MAAqB,EAAE,SAAiC;QAClF,OAAO,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,gBAAgB,CAAC,MAAqB,EAAE,SAAiC;QACpF,MAAM,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACI,eAAe,CAAC,MAAqB,EAAE,UAAkC;QAC9E,MAAM,YAAY,GAAG,yBAAS,CAAC,YAAY,CAAC;QAC5C,OAAO;YACL,KAAK,EAAE;gBACL;oBACE,EAAE,EAAE,YAAY;oBAChB,YAAY,EAAE,EAAE;oBAChB,KAAK,EAAE,YAAY,CAAC,kBAAkB,CAAC,iCAAiC,CAAC;oBACzE,IAAI,EAAE,yBAAyB;oBAC/B,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC;oBAClB,UAAU,EAAE,KAAK;iBAClB;gBACD;oBACE,EAAE,EAAE,cAAc;oBAClB,YAAY,EAAE,EAAE;oBAChB,KAAK,EAAE,YAAY,CAAC,kBAAkB,CAAC,mCAAmC,CAAC;oBAC3E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AAQ,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;YACxF,OAAO,KAAK,CAAC;QAEf,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA9FD,oDA8FC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module HyperModeling\r\n */\r\n\r\nimport { IModelApp } from \"@itwin/core-frontend\";\r\nimport type { AbstractToolbarProps } from \"@itwin/appui-abstract\";\r\nimport { SectionMarker } from \"./SectionMarkers\";\r\nimport { SectionMarkerConfig } from \"./HyperModelingConfig\";\r\nimport { HyperModelingDecorator } from \"./HyperModelingDecorator\";\r\n\r\n/** Supplies interactions with [[SectionMarker]]s, including a mini-toolbar displayed when the mouse hovers over a marker and what action occurs when the user clicks a marker.\r\n * The base implementation supplies the following interactions:\r\n * * Click: Toggle display of the section graphics and clip volume; apply the section's spatial view if toggling on.\r\n * * Toolbar:\r\n * * Apply Section: Applies the section location's spatial view to the viewport and displays the 2d section graphics.\r\n * * Open Drawing: Navigates to the section drawing view. By default, this applies the section drawing view to the viewport.\r\n * * Open Sheet: Navigates to the [ViewAttachment]($backend) of the section drawing on a [Sheet]($backend). Disabled if no such attachment exists.\r\n * @see [[HyperModelingConfig]] to override the default handler by supplying a subclass of `SectionMarkerHandler`.\r\n * @see [[HyperModelingDecorator]] for various methods that might be usefully wired up to marker click or toolbar actions.\r\n * @public\r\n */\r\nexport class SectionMarkerHandler {\r\n /** Respond to activation of the specified marker. Return true if the marker should become the active marker - i.e., if the marker was successfully activated.\r\n * @see [[SectionMarkerHandler.deactivateMarker]].\r\n */\r\n public async activateMarker(marker: SectionMarker, decorator: HyperModelingDecorator): Promise<boolean> {\r\n return decorator.toggleSection(marker, true);\r\n }\r\n\r\n /** Respond to deactivation of the specified marker. Invoked when the user clicks on the marker while it is the active marker.\r\n * This should perform the inverse of [[SectionMarkerHandler.activateMarker]]. The marker becomes inactive as a result.\r\n */\r\n public async deactivateMarker(marker: SectionMarker, decorator: HyperModelingDecorator): Promise<void> {\r\n await decorator.toggleSection(marker, false);\r\n }\r\n\r\n /** Return toolbar items for the specified marker. If the array of toolbar items is empty, no toolbar will be displayed.\r\n * @see [[executeCommand]] to implement each toolbar command.\r\n */\r\n public getToolbarProps(marker: SectionMarker, _decorator: HyperModelingDecorator): AbstractToolbarProps {\r\n const localization = IModelApp.localization;\r\n return {\r\n items: [\r\n {\r\n id: \"apply_view\",\r\n itemPriority: 10,\r\n label: localization.getLocalizedString(\"HyperModeling:Message.ApplyView\"),\r\n icon: \"icon-spatial-view-apply\",\r\n execute: () => { },\r\n isDisabled: false,\r\n },\r\n {\r\n id: \"open_section\",\r\n itemPriority: 20,\r\n label: localization.getLocalizedString(\"HyperModeling:Message.OpenSection\"),\r\n icon: \"icon-plan-drawing\",\r\n execute: () => { },\r\n isDisabled: false,\r\n },\r\n {\r\n id: \"open_sheet\",\r\n itemPriority: 30,\r\n label: localization.getLocalizedString(\"HyperModeling:Message.OpenSheet\"),\r\n icon: \"icon-plan-floor\",\r\n execute: () => { },\r\n isDisabled: undefined === marker.state.viewAttachment?.viewId,\r\n },\r\n ],\r\n };\r\n }\r\n\r\n /** Execute the command associated with the specified tool bar item.\r\n * @see [[getToolbarProps]] to define the set of commands.\r\n */\r\n public async executeCommand(commandId: string, marker: SectionMarker, decorator: HyperModelingDecorator): Promise<void> {\r\n switch (commandId) {\r\n case \"apply_view\":\r\n await decorator.applySpatialView(marker);\r\n break;\r\n case \"open_section\":\r\n await decorator.openSection(marker);\r\n break;\r\n case \"open_sheet\":\r\n await decorator.openSheet(marker);\r\n break;\r\n }\r\n }\r\n\r\n /** Customize which markers are visible. [[HyperModelingDecorator]] determines marker visibility as follows:\r\n * - If a marker is currently active (selected), only that marker is visible.\r\n * - Otherwise, the marker is visible if this method returns `true`.\r\n * The default implementation of this method determines visibility based on the [[SectionMarkerConfig]] as follows.\r\n * - If the marker is of a type included in the config's `hiddenSectionTypes`, it is invisible.\r\n * - If the marker belongs to a model not currently displayed in the viewport and the config's `ignoreModelSelector` is false, it is invisible.\r\n * - If the marker belongs to a category not currently displayed in the viewport and the config's `ignoreCategorySelector` is false, it is invisible,\r\n * - Otherwise, the marker is visible, unless this method returns `false`.\r\n * The default implementation of this method always returns `true`\r\n * @param marker The marker whose visibility is to be determined.\r\n * @param decorator The hypermodeling decorator to which the marker belongs.\r\n * @param config The configuration controlling marker visibility based on [SectionType]($common), [ModelSelectorState]($frontend), and [CategorySelectorState]($frontend).\r\n * @returns true if the marker should be displayed; false to make it invisible.\r\n * @see [[HyperModelingDecorator.requestSync]] to force the decorator to reevaluate marker visibility when the criterion used by your implementation of this method changes.\r\n */\r\n public isMarkerVisible(marker: SectionMarker, decorator: HyperModelingDecorator, config: SectionMarkerConfig): boolean {\r\n if (undefined !== config.hiddenSectionTypes && config.hiddenSectionTypes.includes(marker.state.sectionType))\r\n return false;\r\n\r\n if (!config.ignoreCategorySelector && !decorator.viewport.view.viewsCategory(marker.state.category))\r\n return false;\r\n\r\n if (!config.ignoreModelSelector && !decorator.viewport.view.viewsModel(marker.state.model))\r\n return false;\r\n\r\n return true;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SectionMarkerHandler.js","sourceRoot":"","sources":["../../src/SectionMarkerHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAAiD;AAMjD;;;;;;;;;;GAUG;AACH,MAAa,oBAAoB;IAC/B;;OAEG;IACI,KAAK,CAAC,cAAc,CAAC,MAAqB,EAAE,SAAiC;QAClF,OAAO,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,gBAAgB,CAAC,MAAqB,EAAE,SAAiC;QACpF,MAAM,SAAS,CAA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SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;gBAClC,MAAM;QACV,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACI,eAAe,CAAC,MAAqB,EAAE,SAAiC,EAAE,MAA2B;QAC1G,IAAI,SAAS,KAAK,MAAM,CAAC,kBAAkB,IAAI,MAAM,CAAC,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC;YACzG,OAAO,KAAK,CAAC;QAEf,IAAI,CAAC,MAAM,CAAC,sBAAsB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;YACjG,OAAO,KAAK,CAAC;QAEf,IAAI,CAAC,MAAM,CAAC,mBAAmB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;YACxF,OAAO,KAAK,CAAC;QAEf,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA9FD,oDA8FC","sourcesContent":["/*---------------------------------------------------------------------------------------------\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 { IModelApp } from \"@itwin/core-frontend\";\nimport type { AbstractToolbarProps } from \"@itwin/appui-abstract\";\nimport { SectionMarker } from \"./SectionMarkers\";\nimport { SectionMarkerConfig } from \"./HyperModelingConfig\";\nimport { HyperModelingDecorator } from \"./HyperModelingDecorator\";\n\n/** Supplies interactions with [[SectionMarker]]s, including a mini-toolbar displayed when the mouse hovers over a marker and what action occurs when the user clicks a marker.\n * The base implementation supplies the following interactions:\n * * Click: Toggle display of the section graphics and clip volume; apply the section's spatial view if toggling on.\n * * Toolbar:\n * * Apply Section: Applies the section location's spatial view to the viewport and displays the 2d section graphics.\n * * Open Drawing: Navigates to the section drawing view. By default, this applies the section drawing view to the viewport.\n * * Open Sheet: Navigates to the [ViewAttachment]($backend) of the section drawing on a [Sheet]($backend). Disabled if no such attachment exists.\n * @see [[HyperModelingConfig]] to override the default handler by supplying a subclass of `SectionMarkerHandler`.\n * @see [[HyperModelingDecorator]] for various methods that might be usefully wired up to marker click or toolbar actions.\n * @public\n */\nexport class SectionMarkerHandler {\n /** Respond to activation of the specified marker. Return true if the marker should become the active marker - i.e., if the marker was successfully activated.\n * @see [[SectionMarkerHandler.deactivateMarker]].\n */\n public async activateMarker(marker: SectionMarker, decorator: HyperModelingDecorator): Promise<boolean> {\n return decorator.toggleSection(marker, true);\n }\n\n /** Respond to deactivation of the specified marker. Invoked when the user clicks on the marker while it is the active marker.\n * This should perform the inverse of [[SectionMarkerHandler.activateMarker]]. The marker becomes inactive as a result.\n */\n public async deactivateMarker(marker: SectionMarker, decorator: HyperModelingDecorator): Promise<void> {\n await decorator.toggleSection(marker, false);\n }\n\n /** Return toolbar items for the specified marker. If the array of toolbar items is empty, no toolbar will be displayed.\n * @see [[executeCommand]] to implement each toolbar command.\n */\n public getToolbarProps(marker: SectionMarker, _decorator: HyperModelingDecorator): AbstractToolbarProps {\n const localization = IModelApp.localization;\n return {\n items: [\n {\n id: \"apply_view\",\n itemPriority: 10,\n label: localization.getLocalizedString(\"HyperModeling:Message.ApplyView\"),\n icon: \"icon-spatial-view-apply\",\n execute: () => { },\n isDisabled: false,\n },\n {\n id: \"open_section\",\n itemPriority: 20,\n label: localization.getLocalizedString(\"HyperModeling:Message.OpenSection\"),\n icon: \"icon-plan-drawing\",\n execute: () => { },\n isDisabled: false,\n },\n {\n id: \"open_sheet\",\n itemPriority: 30,\n label: localization.getLocalizedString(\"HyperModeling:Message.OpenSheet\"),\n icon: \"icon-plan-floor\",\n execute: () => { },\n isDisabled: undefined === marker.state.viewAttachment?.viewId,\n },\n ],\n };\n }\n\n /** Execute the command associated with the specified tool bar item.\n * @see [[getToolbarProps]] to define the set of commands.\n */\n public async executeCommand(commandId: string, marker: SectionMarker, decorator: HyperModelingDecorator): Promise<void> {\n switch (commandId) {\n case \"apply_view\":\n await decorator.applySpatialView(marker);\n break;\n case \"open_section\":\n await decorator.openSection(marker);\n break;\n case \"open_sheet\":\n await decorator.openSheet(marker);\n break;\n }\n }\n\n /** Customize which markers are visible. [[HyperModelingDecorator]] determines marker visibility as follows:\n * - If a marker is currently active (selected), only that marker is visible.\n * - Otherwise, the marker is visible if this method returns `true`.\n * The default implementation of this method determines visibility based on the [[SectionMarkerConfig]] as follows.\n * - If the marker is of a type included in the config's `hiddenSectionTypes`, it is invisible.\n * - If the marker belongs to a model not currently displayed in the viewport and the config's `ignoreModelSelector` is false, it is invisible.\n * - If the marker belongs to a category not currently displayed in the viewport and the config's `ignoreCategorySelector` is false, it is invisible,\n * - Otherwise, the marker is visible, unless this method returns `false`.\n * The default implementation of this method always returns `true`\n * @param marker The marker whose visibility is to be determined.\n * @param decorator The hypermodeling decorator to which the marker belongs.\n * @param config The configuration controlling marker visibility based on [SectionType]($common), [ModelSelectorState]($frontend), and [CategorySelectorState]($frontend).\n * @returns true if the marker should be displayed; false to make it invisible.\n * @see [[HyperModelingDecorator.requestSync]] to force the decorator to reevaluate marker visibility when the criterion used by your implementation of this method changes.\n */\n public isMarkerVisible(marker: SectionMarker, decorator: HyperModelingDecorator, config: SectionMarkerConfig): boolean {\n if (undefined !== config.hiddenSectionTypes && config.hiddenSectionTypes.includes(marker.state.sectionType))\n return false;\n\n if (!config.ignoreCategorySelector && !decorator.viewport.view.viewsCategory(marker.state.category))\n return false;\n\n if (!config.ignoreModelSelector && !decorator.viewport.view.viewsModel(marker.state.model))\n return false;\n\n return true;\n }\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;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O,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC5H,CAAC;IAED,mGAAmG;IAC5F,cAAc,CAAC,wBAAoC;QACxD,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO;YAC/B,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,wBAAwB;gBAC9C,OAAO,MAAM,CAAC;QAElB,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAnCD,4CAmCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module HyperModeling\r\n */\r\n\r\nimport { assert, BeEvent, Id64String } from \"@itwin/core-bentley\";\r\nimport { Point2d, Point3d, XAndY, XYAndZ } from \"@itwin/core-geometry\";\r\nimport { IModelReadRpcInterface } from \"@itwin/core-common\";\r\nimport {\r\n BeButton, BeButtonEvent, Cluster, DecorateContext, IModelApp, InputSource, Marker, MarkerImage, MarkerSet, ScreenViewport, ViewClipTool,\r\n} from \"@itwin/core-frontend\";\r\nimport { SectionDrawingLocationState } from \"./SectionDrawingLocationState\";\r\nimport { HyperModeling } from \"./HyperModeling\";\r\n\r\nconst markerSize = Point2d.create(40, 40);\r\n\r\n/** A [Marker]($frontend) associated with a [[SectionDrawingLocationState]], displayed as a canvas decoration at the location of the section.\r\n * Clicking on the marker toggles display of the section graphics. Mousing over the marker produces a toolbar with additional interactions.\r\n * @see [[HyperModelingDecorator]] for a [Decorator]($frontend) capable of displaying section markers for each section drawing location.\r\n * @see [[SectionMarkerHandler]] to customize the marker interactions.\r\n * @public\r\n */\r\nexport class SectionMarker extends Marker {\r\n /** The section drawing location state associated with the marker. */\r\n public readonly state: SectionDrawingLocationState;\r\n /** A description displayed as part of the tooltip when this marker is clustered with other markers. */\r\n public readonly description: string;\r\n /** @internal */\r\n public readonly onMouseEnterEvent = new BeEvent<(marker: SectionMarker) => void>();\r\n /** @internal */\r\n public readonly onMouseButtonEvent = new BeEvent<(marker: SectionMarker) => void>();\r\n /** @internal */\r\n private _isActive = false;\r\n\r\n /** Constructor, typically invoked indirectly via [[HyperModelingDecorator]].\r\n * @param state The section drawing location state this marker will represent.\r\n * @param pos The world coordinates at which to display the marker.\r\n * @param description A brief description of this marker, used as part of the tooltip when this marker is part of a cluster.\r\n * @param icon The icon displayed by the marker.\r\n * @param tooltip Optional detailed tooltip displayed on mouse hover. If undefined, the `description` is used instead.\r\n */\r\n public constructor(state: SectionDrawingLocationState) {\r\n super(state.placement.origin.clone(), markerSize);\r\n this.state = state;\r\n\r\n const data = HyperModeling.getMarkerData(state.sectionType);\r\n this.description = data.label;\r\n if (data.image)\r\n this.setImage(data.image);\r\n\r\n this.setScaleFactor({ low: .2, high: 1.4 }); // make size 20% at back of frustum and 140% at front of frustum (if camera is on)\r\n }\r\n\r\n /** @internal */\r\n public get isHilited(): boolean { return this._isHilited; }\r\n\r\n /** Returns true if this is the \"active\" section marker. At most one marker is active at a given time.\r\n * @see [[HyperModelingDecorator.activeMarker]].\r\n * @see [[HyperModelingDecorator.setActiveMarker]].\r\n * @see [[SectionMarkerHandler.toggleMarker]].\r\n */\r\n public get isActive(): boolean {\r\n return this._isActive;\r\n }\r\n\r\n /** @internal */\r\n public setActive(active: boolean): void {\r\n this._isActive = active;\r\n }\r\n\r\n /** @internal */\r\n protected drawActive(ctx: CanvasRenderingContext2D) {\r\n ctx.shadowBlur = 30;\r\n ctx.shadowColor = \"gold\";\r\n return false;\r\n }\r\n\r\n /** @internal */\r\n public override drawDecoration(ctx: CanvasRenderingContext2D): void {\r\n if (!this.isActive || !this.drawActive(ctx))\r\n super.drawDecoration(ctx);\r\n }\r\n\r\n /** @internal */\r\n public override onMouseEnter(ev: BeButtonEvent) {\r\n // Lazily load the tooltip.\r\n if (undefined === this.title) {\r\n IModelReadRpcInterface.getClientForRouting(this.state.iModel.routingContext.token).getToolTipMessage(this.state.iModel.getRpcProps(), this.state.id).then((tooltipMsg) => {\r\n this.title = IModelApp.formatElementToolTip(tooltipMsg);\r\n }).catch((_) => {\r\n this.title = this.description;\r\n });\r\n }\r\n\r\n super.onMouseEnter(ev);\r\n this.onMouseEnterEvent.raiseEvent(this);\r\n }\r\n\r\n /** @internal */\r\n public override onMouseButton(ev: BeButtonEvent): boolean {\r\n if (InputSource.Mouse === ev.inputSource && BeButton.Data === ev.button && ev.isDown && ev.viewport)\r\n this.onMouseButtonEvent.raiseEvent(this);\r\n\r\n return true; // Don't allow clicks to be sent to active tool...\r\n }\r\n\r\n /** @internal */\r\n public override addMarker(context: DecorateContext) {\r\n super.addMarker(context);\r\n if (this.isHilited)\r\n ViewClipTool.drawClip(context, this.state.clip, undefined, { fillClipPlanes: true, hasPrimaryPlane: true });\r\n }\r\n}\r\n\r\n/** A Marker used to show a cluster of section locations.\r\n * @internal\r\n */\r\nexport class SectionMarkerCluster extends Marker {\r\n /** Create a new cluster marker */\r\n constructor(location: XYAndZ, size: XAndY, cluster: Cluster<SectionMarker>, image: MarkerImage | Promise<MarkerImage> | undefined) {\r\n super(location, size);\r\n\r\n this.imageOffset = new Point3d(0, 30);\r\n this.label = cluster.markers.length.toLocaleString();\r\n this.labelColor = \"black\";\r\n this.labelFont = \"bold 14px sans-serif\";\r\n\r\n const maxLen = 10;\r\n let title = \"\";\r\n cluster.markers.forEach((marker, index: number) => {\r\n if (index < maxLen) {\r\n if (title !== \"\")\r\n title += \"<br>\";\r\n title += marker.description;\r\n }\r\n });\r\n\r\n if (cluster.markers.length > maxLen)\r\n title += \"<br>...\";\r\n\r\n const div = document.createElement(\"div\");\r\n div.innerHTML = title;\r\n this.title = div;\r\n if (image)\r\n this.setImage(image);\r\n }\r\n\r\n /** Show the cluster as a white circle with an outline */\r\n public override drawFunc(ctx: CanvasRenderingContext2D): void {\r\n ctx.beginPath();\r\n ctx.strokeStyle = \"#372528\";\r\n ctx.fillStyle = \"white\";\r\n ctx.lineWidth = 5;\r\n ctx.arc(0, 0, 13, 0, Math.PI * 2);\r\n ctx.fill();\r\n ctx.stroke();\r\n }\r\n\r\n public override onMouseButton(_ev: BeButtonEvent): boolean { return true; } // Don't allow clicks to be sent to active tool...\r\n}\r\n\r\n/** A [MarkerSet]($frontend) containing [[SectionMarker]]s identifying [SectionDrawingLocation]($backend)s within a spatial view.\r\n * Typically used indirectly via [[HyperModelingDecorator]].\r\n * @public\r\n */\r\nexport class SectionMarkerSet extends MarkerSet<SectionMarker> {\r\n public override minimumClusterSize = 5;\r\n\r\n /** Constructor\r\n * @param viewport The viewport in which the markers are to be displayed.\r\n * @param markers The markers to be displayed.\r\n * @note Each marker's [[SectionDrawingLocationState]] must be associated with the same [IModelConnection]($frontend) as the viewport; any markers from other iModels will be omitted.\r\n */\r\n public constructor(viewport: ScreenViewport, markers: SectionMarker[]) {\r\n super(viewport);\r\n for (const marker of markers) {\r\n if (marker.state.iModel === viewport.iModel)\r\n this.markers.add(marker);\r\n }\r\n }\r\n\r\n /** The viewport in which the markers are to be displayed. */\r\n public override get viewport(): ScreenViewport {\r\n assert(undefined !== super.viewport);\r\n return super.viewport;\r\n }\r\n\r\n /** @internal */\r\n protected getClusterMarker(cluster: Cluster<SectionMarker>): Marker {\r\n return new SectionMarkerCluster(cluster.getClusterLocation(), cluster.markers[0].size, cluster, cluster.markers[0].image);\r\n }\r\n\r\n /** Find the SectionMarker corresponding to the specified [SectionDrawingLocation]($backend) Id. */\r\n public findMarkerById(sectionDrawingLocationId: Id64String): SectionMarker | undefined {\r\n for (const marker of this.markers)\r\n if (marker.state.id === sectionDrawingLocationId)\r\n return marker;\r\n\r\n return undefined;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SectionMarkers.js","sourceRoot":"","sources":["../../src/SectionMarkers.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAkE;AAClE,wDAAuE;AACvE,oDAA4D;AAC5D,wD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BAAgB;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":[],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D,MAAM,CAAC,MAA2B;QAC1C,6BAAa,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IACzD,CAAC;;AAJsB,qCAAM,GAAG,qCAAqC,CAAC;AAOxE,MAAM,gCAAiC,SAAQ,uBAAuB;IAG1D,MAAM,CAAC,MAA2B;QAC1C,MAAM,EAAE,GAAG,yBAAS,CAAC,WAAW,CAAC,YAAY,CAAC;QAC9C,MAAM,SAAS,GAAG,EAAE,CAAC,CAAC,CAAC,+CAAsB,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC7E,IAAI,SAAS;YACX,SAAS,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;;AAPsB,uCAAM,GAAG,6BAA6B,CAAC;AAUhE,gBAAgB;AAChB,SAAgB,aAAa,CAAC,SAAiB;IAC7C,MAAM,QAAQ,GAAG,CAAC,IAAiB,EAAE,EAAE,CAAC,yBAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAClF,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAC5B,QAAQ,CAAC,yBAAyB,CAAC,CAAC;IACpC,QAAQ,CAAC,gCAAgC,CAAC,CAAC;IAC3C,QAAQ,CAAC,8BAA8B,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module HyperModeling\r\n */\r\n\r\nimport { SectionType } from \"@itwin/core-common\";\r\nimport { IModelApp, ScreenViewport, Tool } from \"@itwin/core-frontend\";\r\nimport { HyperModeling } from \"./HyperModeling\";\r\nimport { SectionGraphicsConfig, SectionMarkerConfig } from \"./HyperModelingConfig\";\r\nimport { HyperModelingDecorator } from \"./HyperModelingDecorator\";\r\n\r\n/** Parses a string case-insensitively returning true for \"ON\", false for \"OFF\", undefined for \"TOGGLE\" or undefined, and the input string for anything else. */\r\nfunction parseToggle(arg: string | undefined): string | boolean | undefined {\r\n if (undefined === arg)\r\n return undefined;\r\n\r\n switch (arg.toLowerCase()) {\r\n case \"on\": return true;\r\n case \"off\": return false;\r\n case \"toggle\": return undefined;\r\n default: return arg;\r\n }\r\n}\r\n\r\nclass HyperModelingTool extends Tool {\r\n public static override toolId = \"HyperModeling\";\r\n public static override get minArgs() { return 0; }\r\n public static override get maxArgs() { return 1; }\r\n\r\n public override async run(enable?: boolean, vp?: ScreenViewport): Promise<boolean> {\r\n vp = vp ?? IModelApp.viewManager.selectedView;\r\n if (vp)\r\n await HyperModeling.startOrStop(vp, enable);\r\n\r\n return true;\r\n }\r\n\r\n public override async parseAndRun(...args: string[]): Promise<boolean> {\r\n const enable = parseToggle(args[0]);\r\n return typeof enable !== \"string\" && this.run(enable);\r\n }\r\n}\r\n\r\ntype Writeable<T> = { -readonly [P in keyof T]: T[P] };\r\n\r\n/** Configures how section graphics are displayed. These are global settings. If no arguments are supplied, the defaults are restored.\r\n * Otherwise, each argument is of the form \"name=value\" where value is 0 (disable) or 1 (enable). Only the first letter of each argument matters.\r\n * - drawings: Whether to display the section drawing graphics. Default: 1.\r\n * - sheets: Whether to display the sheet annotation graphics. Default: 1.\r\n * - clip: Whether to apply clip volumes to the 2d graphics. Default: 1.\r\n * - boundaries: Whether to display clip volumes as boundary shapes for debugging purposes. Default: 0.\r\n */\r\nclass SectionGraphicsConfigTool extends Tool {\r\n public static override toolId = \"HyperModeling.Graphics.Config\";\r\n public static override get minArgs() { return 0; }\r\n public static override get maxArgs() { return 4; }\r\n\r\n public override async run(config?: SectionGraphicsConfig): Promise<boolean> {\r\n if (!config) {\r\n config = {\r\n ignoreClip: false,\r\n debugClipVolumes: false,\r\n hideSectionGraphics: false,\r\n hideSheetAnnotations: false,\r\n };\r\n }\r\n\r\n HyperModeling.updateConfiguration({ graphics: config });\r\n return true;\r\n }\r\n\r\n public override async parseAndRun(...args: string[]): Promise<boolean> {\r\n if (0 === args.length)\r\n return this.run(); // restore defaults...\r\n\r\n const config: Writeable<SectionGraphicsConfig> = {};\r\n for (const arg of args) {\r\n const parts = arg.toLowerCase().split(\"=\");\r\n if (2 !== parts.length)\r\n continue;\r\n\r\n const value = Number.parseInt(parts[1], 10);\r\n if (Number.isNaN(value) || (0 !== value && 1 !== value))\r\n continue;\r\n\r\n const enable = 1 === value;\r\n switch (parts[0][0]) {\r\n case \"d\":\r\n config.hideSectionGraphics = !enable;\r\n break;\r\n case \"s\":\r\n config.hideSheetAnnotations = !enable;\r\n break;\r\n case \"c\":\r\n config.ignoreClip = !enable;\r\n break;\r\n case \"b\":\r\n config.debugClipVolumes = enable;\r\n break;\r\n }\r\n }\r\n\r\n return this.run(config);\r\n }\r\n}\r\n\r\nabstract class SectionMarkerConfigTool extends Tool {\r\n public static override get minArgs() { return 0; }\r\n public static override get maxArgs() { return 3; }\r\n\r\n protected abstract update(config: SectionMarkerConfig): void;\r\n\r\n public override async run(config?: SectionMarkerConfig): Promise<boolean> {\r\n config = config ?? { ignoreModelSelector: false, ignoreCategorySelector: false, hiddenSectionTypes: [] };\r\n this.update(config);\r\n return true;\r\n }\r\n\r\n public override async parseAndRun(...args: string[]): Promise<boolean> {\r\n if (0 === args.length)\r\n return this.run(); // restore defaults...\r\n\r\n const config: Writeable<SectionMarkerConfig> = {};\r\n for (const arg of args) {\r\n const parts = arg.toLowerCase().split(\"=\");\r\n if (2 !== parts.length)\r\n continue;\r\n\r\n const setting = parts[0][0];\r\n switch (setting) {\r\n case \"h\": {\r\n config.hiddenSectionTypes = [];\r\n for (const c of parts[1]) {\r\n switch (c) {\r\n case \"s\":\r\n config.hiddenSectionTypes.push(SectionType.Section);\r\n break;\r\n case \"d\":\r\n config.hiddenSectionTypes.push(SectionType.Detail);\r\n break;\r\n case \"e\":\r\n config.hiddenSectionTypes.push(SectionType.Elevation);\r\n break;\r\n case \"p\":\r\n config.hiddenSectionTypes.push(SectionType.Plan);\r\n break;\r\n }\r\n }\r\n\r\n break;\r\n }\r\n default: {\r\n const intVal = Number.parseInt(parts[1], 10);\r\n if (!Number.isNaN(intVal) && (0 === intVal || 1 === intVal)) {\r\n if (\"c\" === setting)\r\n config.ignoreCategorySelector = 0 === intVal;\r\n else if (\"m\" === setting)\r\n config.ignoreModelSelector = 0 === intVal;\r\n }\r\n\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return this.run(config);\r\n }\r\n}\r\n\r\nclass SectionMarkerDefaultConfigTool extends SectionMarkerConfigTool {\r\n public static override toolId = \"HyperModeling.Marker.Default.Config\";\r\n\r\n protected update(config: SectionMarkerConfig): void {\r\n HyperModeling.updateConfiguration({ markers: config });\r\n }\r\n}\r\n\r\nclass SectionMarkerDecoratorConfigTool extends SectionMarkerConfigTool {\r\n public static override toolId = \"HyperModeling.Marker.Config\";\r\n\r\n protected update(config: SectionMarkerConfig): void {\r\n const vp = IModelApp.viewManager.selectedView;\r\n const decorator = vp ? HyperModelingDecorator.getForViewport(vp) : undefined;\r\n if (decorator)\r\n decorator.updateConfiguration(config);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function registerTools(namespace: string): void {\r\n const register = (tool: typeof Tool) => IModelApp.tools.register(tool, namespace);\r\n register(HyperModelingTool);\r\n register(SectionGraphicsConfigTool);\r\n register(SectionMarkerDecoratorConfigTool);\r\n register(SectionMarkerDefaultConfigTool);\r\n}\r\n"]}
1
+ {"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,GA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AAG,6BAA6B,CAAC;IAEpD,MAAM,CAAC,MAA2B;QAC1C,MAAM,EAAE,GAAG,yBAAS,CAAC,WAAW,CAAC,YAAY,CAAC;QAC9C,MAAM,SAAS,GAAG,EAAE,CAAC,CAAC,CAAC,+CAAsB,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC7E,IAAI,SAAS;YACX,SAAS,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;;AAGH,gBAAgB;AAChB,SAAgB,aAAa,CAAC,SAAiB;IAC7C,MAAM,QAAQ,GAAG,CAAC,IAAiB,EAAE,EAAE,CAAC,yBAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAClF,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAC5B,QAAQ,CAAC,yBAAyB,CAAC,CAAC;IACpC,QAAQ,CAAC,gCAAgC,CAAC,CAAC;IAC3C,QAAQ,CAAC,8BAA8B,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module HyperModeling\r\n */\r\n\r\nimport { SectionType } from \"@itwin/core-common\";\r\nimport { IModelApp, ScreenViewport, Tool } from \"@itwin/core-frontend\";\r\nimport { HyperModeling } from \"./HyperModeling\";\r\nimport { SectionGraphicsConfig, SectionMarkerConfig } from \"./HyperModelingConfig\";\r\nimport { HyperModelingDecorator } from \"./HyperModelingDecorator\";\r\n\r\n/** Parses a string case-insensitively returning true for \"ON\", false for \"OFF\", undefined for \"TOGGLE\" or undefined, and the input string for anything else. */\r\nfunction parseToggle(arg: string | undefined): string | boolean | undefined {\r\n if (undefined === arg)\r\n return undefined;\r\n\r\n switch (arg.toLowerCase()) {\r\n case \"on\": return true;\r\n case \"off\": return false;\r\n case \"toggle\": return undefined;\r\n default: return arg;\r\n }\r\n}\r\n\r\nclass HyperModelingTool extends Tool {\r\n public static override toolId = \"HyperModeling\";\r\n public static override get minArgs() { return 0; }\r\n public static override get maxArgs() { return 1; }\r\n\r\n public override async run(enable?: boolean, vp?: ScreenViewport): Promise<boolean> {\r\n vp = vp ?? IModelApp.viewManager.selectedView;\r\n if (vp)\r\n await HyperModeling.startOrStop(vp, enable);\r\n\r\n return true;\r\n }\r\n\r\n public override async parseAndRun(...args: string[]): Promise<boolean> {\r\n const enable = parseToggle(args[0]);\r\n return typeof enable !== \"string\" && this.run(enable);\r\n }\r\n}\r\n\r\ntype Writeable<T> = { -readonly [P in keyof T]: T[P] };\r\n\r\n/** Configures how section graphics are displayed. These are global settings. If no arguments are supplied, the defaults are restored.\r\n * Otherwise, each argument is of the form \"name=value\" where value is 0 (disable) or 1 (enable). Only the first letter of each argument matters.\r\n * - drawings: Whether to display the section drawing graphics. Default: 1.\r\n * - sheets: Whether to display the sheet annotation graphics. Default: 1.\r\n * - clip: Whether to apply clip volumes to the 2d graphics. Default: 1.\r\n * - boundaries: Whether to display clip volumes as boundary shapes for debugging purposes. Default: 0.\r\n */\r\nclass SectionGraphicsConfigTool extends Tool {\r\n public static override toolId = \"HyperModeling.Graphics.Config\";\r\n public static override get minArgs() { return 0; }\r\n public static override get maxArgs() { return 4; }\r\n\r\n public override async run(config?: SectionGraphicsConfig): Promise<boolean> {\r\n if (!config) {\r\n config = {\r\n ignoreClip: false,\r\n debugClipVolumes: false,\r\n hideSectionGraphics: false,\r\n hideSheetAnnotations: false,\r\n };\r\n }\r\n\r\n HyperModeling.updateConfiguration({ graphics: config });\r\n return true;\r\n }\r\n\r\n public override async parseAndRun(...args: string[]): Promise<boolean> {\r\n if (0 === args.length)\r\n return this.run(); // restore defaults...\r\n\r\n const config: Writeable<SectionGraphicsConfig> = {};\r\n for (const arg of args) {\r\n const parts = arg.toLowerCase().split(\"=\");\r\n if (2 !== parts.length)\r\n continue;\r\n\r\n const value = Number.parseInt(parts[1], 10);\r\n if (Number.isNaN(value) || (0 !== value && 1 !== value))\r\n continue;\r\n\r\n const enable = 1 === value;\r\n switch (parts[0][0]) {\r\n case \"d\":\r\n config.hideSectionGraphics = !enable;\r\n break;\r\n case \"s\":\r\n config.hideSheetAnnotations = !enable;\r\n break;\r\n case \"c\":\r\n config.ignoreClip = !enable;\r\n break;\r\n case \"b\":\r\n config.debugClipVolumes = enable;\r\n break;\r\n }\r\n }\r\n\r\n return this.run(config);\r\n }\r\n}\r\n\r\nabstract class SectionMarkerConfigTool extends Tool {\r\n public static override get minArgs() { return 0; }\r\n public static override get maxArgs() { return 3; }\r\n\r\n protected abstract update(config: SectionMarkerConfig): void;\r\n\r\n public override async run(config?: SectionMarkerConfig): Promise<boolean> {\r\n config = config ?? { ignoreModelSelector: false, ignoreCategorySelector: false, hiddenSectionTypes: [] };\r\n this.update(config);\r\n return true;\r\n }\r\n\r\n public override async parseAndRun(...args: string[]): Promise<boolean> {\r\n if (0 === args.length)\r\n return this.run(); // restore defaults...\r\n\r\n const config: Writeable<SectionMarkerConfig> = {};\r\n for (const arg of args) {\r\n const parts = arg.toLowerCase().split(\"=\");\r\n if (2 !== parts.length)\r\n continue;\r\n\r\n const setting = parts[0][0];\r\n switch (setting) {\r\n case \"h\": {\r\n config.hiddenSectionTypes = [];\r\n for (const c of parts[1]) {\r\n switch (c) {\r\n case \"s\":\r\n config.hiddenSectionTypes.push(SectionType.Section);\r\n break;\r\n case \"d\":\r\n config.hiddenSectionTypes.push(SectionType.Detail);\r\n break;\r\n case \"e\":\r\n config.hiddenSectionTypes.push(SectionType.Elevation);\r\n break;\r\n case \"p\":\r\n config.hiddenSectionTypes.push(SectionType.Plan);\r\n break;\r\n }\r\n }\r\n\r\n break;\r\n }\r\n default: {\r\n const intVal = Number.parseInt(parts[1], 10);\r\n if (!Number.isNaN(intVal) && (0 === intVal || 1 === intVal)) {\r\n if (\"c\" === setting)\r\n config.ignoreCategorySelector = 0 === intVal;\r\n else if (\"m\" === setting)\r\n config.ignoreModelSelector = 0 === intVal;\r\n }\r\n\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return this.run(config);\r\n }\r\n}\r\n\r\nclass SectionMarkerDefaultConfigTool extends SectionMarkerConfigTool {\r\n public static override toolId = \"HyperModeling.Marker.Default.Config\";\r\n\r\n protected update(config: SectionMarkerConfig): void {\r\n HyperModeling.updateConfiguration({ markers: config });\r\n }\r\n}\r\n\r\nclass SectionMarkerDecoratorConfigTool extends SectionMarkerConfigTool {\r\n public static override toolId = \"HyperModeling.Marker.Config\";\r\n\r\n protected update(config: SectionMarkerConfig): void {\r\n const vp = IModelApp.viewManager.selectedView;\r\n const decorator = vp ? HyperModelingDecorator.getForViewport(vp) : undefined;\r\n if (decorator)\r\n decorator.updateConfiguration(config);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function registerTools(namespace: string): void {\r\n const register = (tool: typeof Tool) => IModelApp.tools.register(tool, namespace);\r\n register(HyperModelingTool);\r\n register(SectionGraphicsConfigTool);\r\n register(SectionMarkerDecoratorConfigTool);\r\n register(SectionMarkerDefaultConfigTool);\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"hypermodeling-frontend.js","sourceRoot":"","sources":["../../src/hypermodeling-frontend.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,kDAAgC;AAChC,wDAAsC;AACtC,2DAAyC;AACzC,yDAAuC;AACvC,gEAA8C;AAC9C,4DAA0C;AAC1C,mDAAiC;AAEjC;;GAEG;AAEH;;GAEG","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nexport * from \"./HyperModeling\";\r\nexport * from \"./HyperModelingConfig\";\r\nexport * from \"./HyperModelingDecorator\";\r\nexport * from \"./SectionMarkerHandler\";\r\nexport * from \"./SectionDrawingLocationState\";\r\nexport * from \"./SectionGraphicsProvider\";\r\nexport * from \"./SectionMarkers\";\r\n\r\n/** @docs-package-description\r\n * The hypermodeling package enables visualization of section drawings in a spatial context.\r\n */\r\n\r\n/** @docs-group-description HyperModeling\r\n * APIs for controlling visualization of section drawings in a spatial context.\r\n */\r\n"]}
1
+ {"version":3,"file":"hypermodeling-frontend.js","sourceRoot":"","sources":["../../src/hypermodeling-frontend.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,kDAAgC;AAChC,wDAAsC;AACtC,2DAAyC;AACzC,yDAAuC;AACvC,gEAA8C;AAC9C,4DAA0C;AAC1C,mDAAiC;AAEjC;;GAEG;AAEH;;GAEG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nexport * from \"./HyperModeling\";\nexport * from \"./HyperModelingConfig\";\nexport * from \"./HyperModelingDecorator\";\nexport * from \"./SectionMarkerHandler\";\nexport * from \"./SectionDrawingLocationState\";\nexport * from \"./SectionGraphicsProvider\";\nexport * from \"./SectionMarkers\";\n\n/** @docs-package-description\n * The hypermodeling package enables visualization of section drawings in a spatial context.\n */\n\n/** @docs-group-description HyperModeling\n * APIs for controlling visualization of section drawings in a spatial context.\n */\n"]}
@@ -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