@itwin/core-common 5.1.0-dev.9 → 5.2.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +91 -1
- package/lib/cjs/BackgroundMapSettings.d.ts +2 -2
- package/lib/cjs/BackgroundMapSettings.js.map +1 -1
- package/lib/cjs/ChangesetProps.d.ts +28 -0
- package/lib/cjs/ChangesetProps.d.ts.map +1 -1
- package/lib/cjs/ChangesetProps.js.map +1 -1
- package/lib/cjs/ClipStyle.d.ts +1 -1
- package/lib/cjs/ClipStyle.d.ts.map +1 -1
- package/lib/cjs/ClipStyle.js.map +1 -1
- package/lib/cjs/CommonLoggerCategory.d.ts +2 -0
- package/lib/cjs/CommonLoggerCategory.d.ts.map +1 -1
- package/lib/cjs/CommonLoggerCategory.js +2 -0
- package/lib/cjs/CommonLoggerCategory.js.map +1 -1
- package/lib/cjs/ConcurrentQuery.d.ts +8 -23
- package/lib/cjs/ConcurrentQuery.d.ts.map +1 -1
- package/lib/cjs/ConcurrentQuery.js +1 -11
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/ContextRealityModel.d.ts +8 -8
- package/lib/cjs/ContextRealityModel.js +8 -8
- package/lib/cjs/ContextRealityModel.js.map +1 -1
- package/lib/cjs/ElementProps.d.ts +64 -54
- package/lib/cjs/ElementProps.d.ts.map +1 -1
- package/lib/cjs/ElementProps.js +6 -6
- package/lib/cjs/ElementProps.js.map +1 -1
- package/lib/cjs/EntityProps.d.ts +10 -10
- package/lib/cjs/EntityProps.d.ts.map +1 -1
- package/lib/cjs/EntityProps.js +4 -2
- package/lib/cjs/EntityProps.js.map +1 -1
- package/lib/cjs/Fonts.d.ts +2 -2
- package/lib/cjs/Fonts.js +1 -1
- package/lib/cjs/Fonts.js.map +1 -1
- package/lib/cjs/GeoCoordinateServices.d.ts +1 -1
- package/lib/cjs/GeoCoordinateServices.js +1 -1
- package/lib/cjs/GeoCoordinateServices.js.map +1 -1
- package/lib/cjs/GeometryParams.d.ts +3 -1
- package/lib/cjs/GeometryParams.d.ts.map +1 -1
- package/lib/cjs/GeometryParams.js +3 -1
- package/lib/cjs/GeometryParams.js.map +1 -1
- package/lib/cjs/GraphicParams.d.ts +1 -0
- package/lib/cjs/GraphicParams.d.ts.map +1 -1
- package/lib/cjs/GraphicParams.js +1 -0
- package/lib/cjs/GraphicParams.js.map +1 -1
- package/lib/cjs/IModel.d.ts +3 -3
- package/lib/cjs/IModel.js.map +1 -1
- package/lib/cjs/ITwinCoreErrors.d.ts +1 -1
- package/lib/cjs/ITwinCoreErrors.d.ts.map +1 -1
- package/lib/cjs/ITwinCoreErrors.js.map +1 -1
- package/lib/cjs/MassProperties.d.ts +2 -2
- package/lib/cjs/MassProperties.js.map +1 -1
- package/lib/cjs/MaterialProps.d.ts +6 -3
- package/lib/cjs/MaterialProps.d.ts.map +1 -1
- package/lib/cjs/MaterialProps.js.map +1 -1
- package/lib/cjs/RenderSchedule.d.ts +14 -0
- package/lib/cjs/RenderSchedule.d.ts.map +1 -1
- package/lib/cjs/RenderSchedule.js +4 -0
- package/lib/cjs/RenderSchedule.js.map +1 -1
- package/lib/cjs/RenderTexture.d.ts +1 -1
- package/lib/cjs/RenderTexture.d.ts.map +1 -1
- package/lib/cjs/RenderTexture.js.map +1 -1
- package/lib/cjs/TerrainSettings.d.ts +1 -1
- package/lib/cjs/TerrainSettings.d.ts.map +1 -1
- package/lib/cjs/TerrainSettings.js.map +1 -1
- package/lib/cjs/annotation/TextAnnotation.d.ts +78 -2
- package/lib/cjs/annotation/TextAnnotation.d.ts.map +1 -1
- package/lib/cjs/annotation/TextAnnotation.js +63 -10
- package/lib/cjs/annotation/TextAnnotation.js.map +1 -1
- package/lib/cjs/annotation/TextBlock.d.ts +179 -44
- package/lib/cjs/annotation/TextBlock.d.ts.map +1 -1
- package/lib/cjs/annotation/TextBlock.js +210 -57
- package/lib/cjs/annotation/TextBlock.js.map +1 -1
- package/lib/cjs/annotation/TextBlockGeometryProps.d.ts +1 -1
- package/lib/cjs/annotation/TextBlockGeometryProps.js.map +1 -1
- package/lib/cjs/annotation/TextBlockLayoutResult.d.ts +1 -1
- package/lib/cjs/annotation/TextBlockLayoutResult.d.ts.map +1 -1
- package/lib/cjs/annotation/TextBlockLayoutResult.js.map +1 -1
- package/lib/cjs/annotation/TextStyle.d.ts +115 -34
- package/lib/cjs/annotation/TextStyle.d.ts.map +1 -1
- package/lib/cjs/annotation/TextStyle.js +118 -37
- package/lib/cjs/annotation/TextStyle.js.map +1 -1
- package/lib/cjs/geometry/AdditionalTransform.d.ts +4 -0
- package/lib/cjs/geometry/AdditionalTransform.d.ts.map +1 -1
- package/lib/cjs/geometry/AdditionalTransform.js +9 -0
- package/lib/cjs/geometry/AdditionalTransform.js.map +1 -1
- package/lib/cjs/geometry/ElementGeometry.d.ts +1 -1
- package/lib/cjs/geometry/ElementGeometry.d.ts.map +1 -1
- package/lib/cjs/geometry/ElementGeometry.js +2 -2
- package/lib/cjs/geometry/ElementGeometry.js.map +1 -1
- package/lib/cjs/internal/BackendTypes.d.ts +3 -3
- package/lib/cjs/internal/BackendTypes.d.ts.map +1 -1
- package/lib/cjs/internal/BackendTypes.js.map +1 -1
- package/lib/cjs/internal/RenderMesh.d.ts +19 -5
- package/lib/cjs/internal/RenderMesh.d.ts.map +1 -1
- package/lib/cjs/internal/RenderMesh.js +11 -8
- package/lib/cjs/internal/RenderMesh.js.map +1 -1
- package/lib/cjs/internal/cross-package.d.ts +1 -1
- package/lib/cjs/internal/cross-package.d.ts.map +1 -1
- package/lib/cjs/internal/cross-package.js.map +1 -1
- package/lib/cjs/rpc/IModelReadRpcInterface.d.ts +1 -1
- package/lib/cjs/rpc/IModelReadRpcInterface.d.ts.map +1 -1
- package/lib/cjs/rpc/IModelReadRpcInterface.js +1 -1
- package/lib/cjs/rpc/IModelReadRpcInterface.js.map +1 -1
- package/lib/cjs/rpc/SnapshotIModelRpcInterface.d.ts +4 -4
- package/lib/cjs/rpc/SnapshotIModelRpcInterface.js +4 -4
- package/lib/cjs/rpc/SnapshotIModelRpcInterface.js.map +1 -1
- package/lib/cjs/rpc/core/RpcConstants.d.ts +6 -6
- package/lib/cjs/rpc/core/RpcConstants.d.ts.map +1 -1
- package/lib/cjs/rpc/core/RpcConstants.js +6 -6
- package/lib/cjs/rpc/core/RpcConstants.js.map +1 -1
- package/lib/cjs/rpc/web/OpenAPI.d.ts +1 -1
- package/lib/cjs/rpc/web/OpenAPI.js.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcLogging.js.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcProtocol.d.ts +2 -2
- package/lib/cjs/rpc/web/WebAppRpcProtocol.js.map +1 -1
- package/lib/cjs/tile/IModelTileIO.d.ts +2 -2
- package/lib/cjs/tile/IModelTileIO.js +2 -2
- package/lib/cjs/tile/IModelTileIO.js.map +1 -1
- package/lib/cjs/tile/TileMetadata.d.ts +6 -2
- package/lib/cjs/tile/TileMetadata.d.ts.map +1 -1
- package/lib/cjs/tile/TileMetadata.js +10 -4
- package/lib/cjs/tile/TileMetadata.js.map +1 -1
- package/lib/esm/BackgroundMapSettings.d.ts +2 -2
- package/lib/esm/BackgroundMapSettings.js.map +1 -1
- package/lib/esm/ChangesetProps.d.ts +28 -0
- package/lib/esm/ChangesetProps.d.ts.map +1 -1
- package/lib/esm/ChangesetProps.js.map +1 -1
- package/lib/esm/ClipStyle.d.ts +1 -1
- package/lib/esm/ClipStyle.d.ts.map +1 -1
- package/lib/esm/ClipStyle.js.map +1 -1
- package/lib/esm/CommonLoggerCategory.d.ts +2 -0
- package/lib/esm/CommonLoggerCategory.d.ts.map +1 -1
- package/lib/esm/CommonLoggerCategory.js +2 -0
- package/lib/esm/CommonLoggerCategory.js.map +1 -1
- package/lib/esm/ConcurrentQuery.d.ts +8 -23
- package/lib/esm/ConcurrentQuery.d.ts.map +1 -1
- package/lib/esm/ConcurrentQuery.js +1 -11
- package/lib/esm/ConcurrentQuery.js.map +1 -1
- package/lib/esm/ContextRealityModel.d.ts +8 -8
- package/lib/esm/ContextRealityModel.js +8 -8
- package/lib/esm/ContextRealityModel.js.map +1 -1
- package/lib/esm/ElementProps.d.ts +64 -54
- package/lib/esm/ElementProps.d.ts.map +1 -1
- package/lib/esm/ElementProps.js +6 -6
- package/lib/esm/ElementProps.js.map +1 -1
- package/lib/esm/EntityProps.d.ts +10 -10
- package/lib/esm/EntityProps.d.ts.map +1 -1
- package/lib/esm/EntityProps.js +4 -2
- package/lib/esm/EntityProps.js.map +1 -1
- package/lib/esm/Fonts.d.ts +2 -2
- package/lib/esm/Fonts.js +1 -1
- package/lib/esm/Fonts.js.map +1 -1
- package/lib/esm/GeoCoordinateServices.d.ts +1 -1
- package/lib/esm/GeoCoordinateServices.js +1 -1
- package/lib/esm/GeoCoordinateServices.js.map +1 -1
- package/lib/esm/GeometryParams.d.ts +3 -1
- package/lib/esm/GeometryParams.d.ts.map +1 -1
- package/lib/esm/GeometryParams.js +3 -1
- package/lib/esm/GeometryParams.js.map +1 -1
- package/lib/esm/GraphicParams.d.ts +1 -0
- package/lib/esm/GraphicParams.d.ts.map +1 -1
- package/lib/esm/GraphicParams.js +1 -0
- package/lib/esm/GraphicParams.js.map +1 -1
- package/lib/esm/IModel.d.ts +3 -3
- package/lib/esm/IModel.js.map +1 -1
- package/lib/esm/ITwinCoreErrors.d.ts +1 -1
- package/lib/esm/ITwinCoreErrors.d.ts.map +1 -1
- package/lib/esm/ITwinCoreErrors.js.map +1 -1
- package/lib/esm/MassProperties.d.ts +2 -2
- package/lib/esm/MassProperties.js.map +1 -1
- package/lib/esm/MaterialProps.d.ts +6 -3
- package/lib/esm/MaterialProps.d.ts.map +1 -1
- package/lib/esm/MaterialProps.js.map +1 -1
- package/lib/esm/RenderSchedule.d.ts +14 -0
- package/lib/esm/RenderSchedule.d.ts.map +1 -1
- package/lib/esm/RenderSchedule.js +4 -0
- package/lib/esm/RenderSchedule.js.map +1 -1
- package/lib/esm/RenderTexture.d.ts +1 -1
- package/lib/esm/RenderTexture.d.ts.map +1 -1
- package/lib/esm/RenderTexture.js.map +1 -1
- package/lib/esm/TerrainSettings.d.ts +1 -1
- package/lib/esm/TerrainSettings.d.ts.map +1 -1
- package/lib/esm/TerrainSettings.js.map +1 -1
- package/lib/esm/annotation/TextAnnotation.d.ts +78 -2
- package/lib/esm/annotation/TextAnnotation.d.ts.map +1 -1
- package/lib/esm/annotation/TextAnnotation.js +63 -10
- package/lib/esm/annotation/TextAnnotation.js.map +1 -1
- package/lib/esm/annotation/TextBlock.d.ts +179 -44
- package/lib/esm/annotation/TextBlock.d.ts.map +1 -1
- package/lib/esm/annotation/TextBlock.js +207 -56
- package/lib/esm/annotation/TextBlock.js.map +1 -1
- package/lib/esm/annotation/TextBlockGeometryProps.d.ts +1 -1
- package/lib/esm/annotation/TextBlockGeometryProps.js.map +1 -1
- package/lib/esm/annotation/TextBlockLayoutResult.d.ts +1 -1
- package/lib/esm/annotation/TextBlockLayoutResult.d.ts.map +1 -1
- package/lib/esm/annotation/TextBlockLayoutResult.js.map +1 -1
- package/lib/esm/annotation/TextStyle.d.ts +115 -34
- package/lib/esm/annotation/TextStyle.d.ts.map +1 -1
- package/lib/esm/annotation/TextStyle.js +116 -34
- package/lib/esm/annotation/TextStyle.js.map +1 -1
- package/lib/esm/geometry/AdditionalTransform.d.ts +4 -0
- package/lib/esm/geometry/AdditionalTransform.d.ts.map +1 -1
- package/lib/esm/geometry/AdditionalTransform.js +10 -1
- package/lib/esm/geometry/AdditionalTransform.js.map +1 -1
- package/lib/esm/geometry/ElementGeometry.d.ts +1 -1
- package/lib/esm/geometry/ElementGeometry.d.ts.map +1 -1
- package/lib/esm/geometry/ElementGeometry.js +2 -2
- package/lib/esm/geometry/ElementGeometry.js.map +1 -1
- package/lib/esm/internal/BackendTypes.d.ts +3 -3
- package/lib/esm/internal/BackendTypes.d.ts.map +1 -1
- package/lib/esm/internal/BackendTypes.js.map +1 -1
- package/lib/esm/internal/RenderMesh.d.ts +19 -5
- package/lib/esm/internal/RenderMesh.d.ts.map +1 -1
- package/lib/esm/internal/RenderMesh.js +11 -8
- package/lib/esm/internal/RenderMesh.js.map +1 -1
- package/lib/esm/internal/cross-package.d.ts +1 -1
- package/lib/esm/internal/cross-package.d.ts.map +1 -1
- package/lib/esm/internal/cross-package.js.map +1 -1
- package/lib/esm/rpc/IModelReadRpcInterface.d.ts +1 -1
- package/lib/esm/rpc/IModelReadRpcInterface.d.ts.map +1 -1
- package/lib/esm/rpc/IModelReadRpcInterface.js +1 -1
- package/lib/esm/rpc/IModelReadRpcInterface.js.map +1 -1
- package/lib/esm/rpc/SnapshotIModelRpcInterface.d.ts +4 -4
- package/lib/esm/rpc/SnapshotIModelRpcInterface.js +4 -4
- package/lib/esm/rpc/SnapshotIModelRpcInterface.js.map +1 -1
- package/lib/esm/rpc/core/RpcConstants.d.ts +6 -6
- package/lib/esm/rpc/core/RpcConstants.d.ts.map +1 -1
- package/lib/esm/rpc/core/RpcConstants.js +6 -6
- package/lib/esm/rpc/core/RpcConstants.js.map +1 -1
- package/lib/esm/rpc/web/OpenAPI.d.ts +1 -1
- package/lib/esm/rpc/web/OpenAPI.js.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcLogging.js.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcProtocol.d.ts +2 -2
- package/lib/esm/rpc/web/WebAppRpcProtocol.js.map +1 -1
- package/lib/esm/tile/IModelTileIO.d.ts +2 -2
- package/lib/esm/tile/IModelTileIO.js +2 -2
- package/lib/esm/tile/IModelTileIO.js.map +1 -1
- package/lib/esm/tile/TileMetadata.d.ts +6 -2
- package/lib/esm/tile/TileMetadata.d.ts.map +1 -1
- package/lib/esm/tile/TileMetadata.js +10 -4
- package/lib/esm/tile/TileMetadata.js.map +1 -1
- package/package.json +9 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextBlockLayoutResult.js","sourceRoot":"","sources":["../../../src/annotation/TextBlockLayoutResult.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Annotation\n */\n\nimport { Range2dProps, XAndY } from \"@itwin/core-geometry\";\nimport { FontId } from \"../Fonts\";\nimport { TextStyleSettingsProps } from \"./TextStyle\";\n\n/**\n * Represents a single run in a [[LineLayoutResult]].\n * @note Get the text content of the RunLayoutResult using a combination of the `sourceRunIndex`, `characterOffset`, and `characterCount`.\n * @beta\n */\nexport interface RunLayoutResult {\n /** The index of the Run this RunLayoutResult was generated from in [[Paragraph.runs]]. */\n sourceRunIndex: number;\n /** The ID of the font for the run. */\n fontId: FontId;\n /**\n * The number of characters from the source [[Run]] that have already appeared in the layout.\n * @note A single source [[TextRun]] can be split into multiple lines to respect the [[TextBlock.width]].\n */\n characterOffset: number;\n /** The number of characters in the RunLayoutResult. */\n characterCount: number;\n /** The offset of the RunLayoutResult from the top and left of the [[LineLayoutResult]] */\n offsetFromLine: XAndY;\n /** Bounding box enclosing this RunLayoutResult's content. */\n range: Range2dProps;\n /** The [[TextStyleSettings]] for the run. */\n textStyle: TextStyleSettingsProps;\n /** Bounding box used when justifying the run. This may be smaller than [[range]]. */\n justificationRange?: Range2dProps;\n /** The range containing the contents of the [[FractionRun]]'s numerator. */\n numeratorRange?: Range2dProps;\n /** The range containing the contents of the [[FractionRun]]'s denominator. */\n denominatorRange?: Range2dProps;\n}\n\n/**\n * Represents a single line in a [[TextBlockLayoutResult]].\n * @beta\n */\nexport interface LineLayoutResult {\n /** The index of the paragraph this LineLayoutResult was generated from in [[TextBlock.paragraphs]]. */\n sourceParagraphIndex: number;\n /** The runs contained in the line. */\n runs: RunLayoutResult[];\n /** The range containing the contents of the line. */\n range: Range2dProps;\n /** Bounding box used when justifying the line. This may be smaller than [[range]]. */\n justificationRange: Range2dProps;\n /** The offset of the line from the top and left of the [[TextBlock]]. */\n offsetFromDocument: XAndY;\n}\n\n/**\n * Represents the result of laying out a [[TextBlock]]'s contents into a series of lines containing runs.\n * @see [computeLayoutTextBlockResult]($backend) to lay out a `TextBlock`.\n * @beta\n */\nexport interface TextBlockLayoutResult {\n /** The laid out lines of a [[TextBlock]]. */\n lines: LineLayoutResult[];\n /** The range containing the contents of a [[TextBlock]]. */\n range: Range2dProps;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TextBlockLayoutResult.js","sourceRoot":"","sources":["../../../src/annotation/TextBlockLayoutResult.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Annotation\n */\n\nimport { Range2dProps, XAndY } from \"@itwin/core-geometry\";\nimport { FontId } from \"../Fonts\";\nimport { TextStyleSettingsProps } from \"./TextStyle\";\n\n/**\n * Represents a single run in a [[LineLayoutResult]].\n * @note Get the text content of the RunLayoutResult using a combination of the `sourceRunIndex`, `characterOffset`, and `characterCount`.\n * @beta\n */\nexport interface RunLayoutResult {\n /** The index of the Run this RunLayoutResult was generated from in [[Paragraph.runs]]. */\n sourceRunIndex: number;\n /** The ID of the font for the run. */\n fontId: FontId;\n /**\n * The number of characters from the source [[Run]] that have already appeared in the layout.\n * @note A single source [[TextRun]] can be split into multiple lines to respect the [[TextBlock.width]].\n */\n characterOffset: number;\n /** The number of characters in the RunLayoutResult. */\n characterCount: number;\n /** The offset of the RunLayoutResult from the top and left of the [[LineLayoutResult]] */\n offsetFromLine: XAndY;\n /** Bounding box enclosing this RunLayoutResult's content. */\n range: Range2dProps;\n /** The resolved [[TextStyleSettings]] for the run. Takes into account overrides and styles on the parent classes. */\n textStyle: TextStyleSettingsProps;\n /** Bounding box used when justifying the run. This may be smaller than [[range]]. */\n justificationRange?: Range2dProps;\n /** The range containing the contents of the [[FractionRun]]'s numerator. */\n numeratorRange?: Range2dProps;\n /** The range containing the contents of the [[FractionRun]]'s denominator. */\n denominatorRange?: Range2dProps;\n}\n\n/**\n * Represents a single line in a [[TextBlockLayoutResult]].\n * @beta\n */\nexport interface LineLayoutResult {\n /** The index of the paragraph this LineLayoutResult was generated from in [[TextBlock.paragraphs]]. */\n sourceParagraphIndex: number;\n /** The runs contained in the line. */\n runs: RunLayoutResult[];\n /** The range containing the contents of the line. */\n range: Range2dProps;\n /** Bounding box used when justifying the line. This may be smaller than [[range]]. */\n justificationRange: Range2dProps;\n /** The offset of the line from the top and left of the [[TextBlock]]. */\n offsetFromDocument: XAndY;\n}\n\n/**\n * Represents the result of laying out a [[TextBlock]]'s contents into a series of lines containing runs.\n * @see [computeLayoutTextBlockResult]($backend) to lay out a `TextBlock`.\n * @beta\n */\nexport interface TextBlockLayoutResult {\n /** The laid out lines of a [[TextBlock]]. */\n lines: LineLayoutResult[];\n /** The range containing the contents of a [[TextBlock]]. */\n range: Range2dProps;\n}\n"]}
|
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Annotation
|
|
3
3
|
*/
|
|
4
|
+
import { DeepReadonlyObject, DeepRequiredObject } from "@itwin/core-bentley";
|
|
4
5
|
import { ColorDefProps } from "../ColorDef";
|
|
6
|
+
/** Set of predefined shapes that can be computed and drawn around the margins of a [[TextBlock]]
|
|
7
|
+
* @beta
|
|
8
|
+
*/
|
|
9
|
+
export declare const textAnnotationFrameShapes: readonly ["none", "line", "rectangle", "circle", "equilateralTriangle", "diamond", "square", "pentagon", "hexagon", "octagon", "capsule", "roundedRectangle"];
|
|
10
|
+
/** Describes a predefined shape that can be computed and drawn around the margins of a [[TextBlock]]
|
|
11
|
+
* @beta
|
|
12
|
+
*/
|
|
13
|
+
export type TextAnnotationFrameShape = typeof textAnnotationFrameShapes[number];
|
|
14
|
+
/**
|
|
15
|
+
* Describes what color to use when filling the frame around a [[TextBlock]].
|
|
16
|
+
* If `background` is specified, [[GeometryParams.BackgroundFill]] will be set to `BackgroundFill.Outline`.
|
|
17
|
+
* If `none` is specified, no fill will be applied.
|
|
18
|
+
* @beta
|
|
19
|
+
*/
|
|
20
|
+
export type TextAnnotationFillColor = TextStyleColor | "background" | "none";
|
|
5
21
|
/** Specifies how to separate the numerator and denominator of a [[FractionRun]], by either a horizontal or diagonal bar.
|
|
6
22
|
* @see [[TextStyleSettingsProps.stackedFractionType]] and [[TextStyleSettings.stackedFractionType]].
|
|
7
23
|
* @beta
|
|
@@ -13,7 +29,53 @@ export type StackedFractionType = "horizontal" | "diagonal";
|
|
|
13
29
|
* @beta
|
|
14
30
|
*/
|
|
15
31
|
export type TextStyleColor = ColorDefProps | "subcategory";
|
|
16
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Describes how to draw the frame around a [[TextAnnotation]].
|
|
34
|
+
* The frame can be a simple line, a filled shape, or both.
|
|
35
|
+
* If only a subset of properties are specified, the others will be set to their default value.
|
|
36
|
+
* @beta
|
|
37
|
+
*/
|
|
38
|
+
export interface TextFrameStyleProps {
|
|
39
|
+
/** Shape of the frame. Default: "none" */
|
|
40
|
+
shape?: TextAnnotationFrameShape;
|
|
41
|
+
/** The color to fill the shape of the text frame. This fill is applied using [[FillDisplay.Blanking]]. Default: "none" */
|
|
42
|
+
fill?: TextAnnotationFillColor;
|
|
43
|
+
/** The color of the text frame's outline. Default: black */
|
|
44
|
+
border?: TextStyleColor;
|
|
45
|
+
/** This will be used to set the [[GeometryParams.weight]] property of the frame (in pixels). Default: 1px */
|
|
46
|
+
borderWeight?: number;
|
|
47
|
+
}
|
|
48
|
+
/** Properties describing the appearance of [[TextAnnotationLeader]] in a [[TextAnnotation]].
|
|
49
|
+
* Used when producing geometry for [[TextAnnotation]].
|
|
50
|
+
* @beta
|
|
51
|
+
*/
|
|
52
|
+
export interface TextLeaderStyleProps {
|
|
53
|
+
/** The color of the leader.
|
|
54
|
+
* If `inherit` is specified, the [[TextAnnotationLeader]] will use the color specified in the parent [[TextStyleSettings]]`.
|
|
55
|
+
* Default: "inherit".
|
|
56
|
+
*/
|
|
57
|
+
color?: TextStyleColor | "inherit";
|
|
58
|
+
/** Whether to use an elbow in the leader.
|
|
59
|
+
* Default: false
|
|
60
|
+
*/
|
|
61
|
+
wantElbow?: boolean;
|
|
62
|
+
/** Multiplier used to compute length of the elbow in the leader.
|
|
63
|
+
* The elbowLength is computed in meters as elbowLength * [[lineHeight]].
|
|
64
|
+
* Default: 1.0
|
|
65
|
+
*/
|
|
66
|
+
elbowLength?: number;
|
|
67
|
+
/** Multiplier to compute height of the leader terminator.
|
|
68
|
+
* The terminator height is computed in meters as terminatorHeight * [[lineHeight]].
|
|
69
|
+
* Default: 1.0
|
|
70
|
+
*/
|
|
71
|
+
terminatorHeightFactor?: number;
|
|
72
|
+
/** Multiplier to compute width of the leader terminator.
|
|
73
|
+
* The terminator width is computed in meters as terminatorWidth * [[lineHeight]].
|
|
74
|
+
* Default: 1.0
|
|
75
|
+
*/
|
|
76
|
+
terminatorWidthFactor?: number;
|
|
77
|
+
}
|
|
78
|
+
/** Serves both as the JSON representation of a [[TextStyleSettings]], and a way for a [[TextBlockComponent]] to selectively override aspects of a [AnnotationTextStyle]($backend)'s properties.
|
|
17
79
|
* @beta
|
|
18
80
|
*/
|
|
19
81
|
export interface TextStyleSettingsProps {
|
|
@@ -21,12 +83,12 @@ export interface TextStyleSettingsProps {
|
|
|
21
83
|
* Default: "subcategory".
|
|
22
84
|
*/
|
|
23
85
|
color?: TextStyleColor;
|
|
24
|
-
/** The name of a font stored in
|
|
86
|
+
/** The name of a font stored in an iModel, used to draw the contents of a [[TextRun]].
|
|
25
87
|
* Default: "" (an invalid font name).
|
|
26
88
|
*/
|
|
27
89
|
fontName?: string;
|
|
28
90
|
/** The height each line of text, in meters. Many other settings use the line height as the basis for computing their own values.
|
|
29
|
-
* For example, the height and offset from baseline of a subscript [[TextRun]] are
|
|
91
|
+
* For example, the height and offset from baseline of a subscript [[TextRun]] are computed as lineHeight * [[subScriptScale]] and
|
|
30
92
|
* lineHeight * [[subScriptOffsetFactor]], respectively.
|
|
31
93
|
* Default: 1.0. */
|
|
32
94
|
lineHeight?: number;
|
|
@@ -80,9 +142,25 @@ export interface TextStyleSettingsProps {
|
|
|
80
142
|
* Default: 1.0
|
|
81
143
|
*/
|
|
82
144
|
widthFactor?: number;
|
|
145
|
+
/** Properties describing appearance of leaders in a [[TextAnnotation]]
|
|
146
|
+
* Used when producing geometry for [[TextAnnotation]]
|
|
147
|
+
* Default: {color:"subcategory", wantElbow:"false",elbowLength:1, terminatorWidthFactor:1, terminatorHeightFactor:1}.
|
|
148
|
+
*/
|
|
149
|
+
leader?: TextLeaderStyleProps;
|
|
150
|
+
/** The size (in meters) used to calculate the tab stops in a run.
|
|
151
|
+
* These are equally spaced from the left edge of the TextBlock.
|
|
152
|
+
* Default: 4 meters.
|
|
153
|
+
*/
|
|
154
|
+
tabInterval?: number;
|
|
155
|
+
/**
|
|
156
|
+
* A description of the frame around the text annotation.
|
|
157
|
+
* Used when producing geometry for [[TextAnnotation]]s.
|
|
158
|
+
* Default: {shape: "none", fill: "none", border: black, borderWeight: 1} for no frame.
|
|
159
|
+
*/
|
|
160
|
+
frame?: TextFrameStyleProps;
|
|
83
161
|
}
|
|
84
162
|
/** A description of the formatting to be applied to a [[TextBlockComponent]].
|
|
85
|
-
* Named instances of these settings can be stored as [
|
|
163
|
+
* Named instances of these settings can be stored as [AnnotationTextStyle]($backend)s in an iModel.
|
|
86
164
|
* @note This is an immutable type. Use [[clone]] to create a modified copy.
|
|
87
165
|
* @see [[TextStyleSettingsProps]] for documentation of each of the settings.
|
|
88
166
|
* @beta
|
|
@@ -90,11 +168,11 @@ export interface TextStyleSettingsProps {
|
|
|
90
168
|
export declare class TextStyleSettings {
|
|
91
169
|
/** The color of the text. */
|
|
92
170
|
readonly color: TextStyleColor;
|
|
93
|
-
/** The name of a font stored in
|
|
171
|
+
/** The name of a font stored in an iModel, used to draw the contents of a [[TextRun]].
|
|
94
172
|
*/
|
|
95
173
|
readonly fontName: string;
|
|
96
174
|
/** The height each line of text, in meters. Many other settings use the line height as the basis for computing their own values.
|
|
97
|
-
* For example, the height and offset from baseline of a subscript [[TextRun]] are
|
|
175
|
+
* For example, the height and offset from baseline of a subscript [[TextRun]] are computed as lineHeight * [[subScriptScale]] and
|
|
98
176
|
* lineHeight * [[subScriptOffsetFactor]], respectively.
|
|
99
177
|
*/
|
|
100
178
|
readonly lineHeight: number;
|
|
@@ -132,42 +210,45 @@ export declare class TextStyleSettings {
|
|
|
132
210
|
readonly superScriptScale: number;
|
|
133
211
|
/** Multiplier used to compute the width of each glyph, relative to [[lineHeight]]. */
|
|
134
212
|
readonly widthFactor: number;
|
|
135
|
-
/**
|
|
136
|
-
|
|
213
|
+
/** Properties describing appearance of leaders in a [[TextAnnotation]].
|
|
214
|
+
* Used when producing geometry for [[TextAnnotation]].
|
|
215
|
+
*/
|
|
216
|
+
readonly leader: Readonly<Required<TextLeaderStyleProps>>;
|
|
217
|
+
/** The size (in meters) used to calculate the tab stops in a run.
|
|
218
|
+
* These are equally spaced from the left edge of the TextBlock. Default is 4 meters.
|
|
219
|
+
*/
|
|
220
|
+
readonly tabInterval: number;
|
|
221
|
+
/** The frame settings of the [[TextAnnotation]]. */
|
|
222
|
+
readonly frame: Readonly<Required<TextFrameStyleProps>>;
|
|
223
|
+
/** A fully-populated JSON representation of the default settings. A real `fontName` must be provided before use. */
|
|
224
|
+
static defaultProps: DeepReadonlyObject<DeepRequiredObject<TextStyleSettingsProps>>;
|
|
137
225
|
/** Settings initialized to all default values. */
|
|
138
226
|
static defaults: TextStyleSettings;
|
|
139
227
|
private constructor();
|
|
140
228
|
/** Create a copy of these settings, modified according to the properties defined by `alteredProps`. */
|
|
141
229
|
clone(alteredProps?: TextStyleSettingsProps): TextStyleSettings;
|
|
230
|
+
/** Creates a deep copy of the `TextStyleSettingsProps`. */
|
|
231
|
+
static cloneProps(props: TextStyleSettingsProps): TextStyleSettingsProps;
|
|
142
232
|
/** Create settings from their JSON representation. */
|
|
143
233
|
static fromJSON(props?: TextStyleSettingsProps): TextStyleSettings;
|
|
144
234
|
toJSON(): TextStyleSettingsProps;
|
|
235
|
+
/** Compare two [[TextLeaderStyleProps]] for equality.
|
|
236
|
+
* @param other The other leader style properties to compare against.
|
|
237
|
+
* @returns true if the two leader styles are equal, false otherwise.
|
|
238
|
+
*/
|
|
239
|
+
leaderEquals(other: TextLeaderStyleProps): boolean;
|
|
240
|
+
frameEquals(other: TextFrameStyleProps): boolean;
|
|
145
241
|
equals(other: TextStyleSettings): boolean;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
* @see [[TextBlockComponent.styleName]] to define the text style for a component of a [[TextBlock]].
|
|
158
|
-
* @note This is an immutable type. Use [[clone]] to create a modified copy.
|
|
159
|
-
* @beta
|
|
160
|
-
*/
|
|
161
|
-
export declare class TextStyle {
|
|
162
|
-
readonly name: string;
|
|
163
|
-
readonly settings: TextStyleSettings;
|
|
164
|
-
private constructor();
|
|
165
|
-
/** Create a style from its JSON representation. */
|
|
166
|
-
static fromJSON(json: TextStyleProps): TextStyle;
|
|
167
|
-
/** Create a new style. */
|
|
168
|
-
static create(name: string, settings: TextStyleSettings): TextStyle;
|
|
169
|
-
/** Create a copy of this style with the same name, and settings modified according to the properties defined by `alteredSettings`. */
|
|
170
|
-
clone(alteredSettings: TextStyleSettingsProps): TextStyle;
|
|
171
|
-
equals(other: TextStyle): boolean;
|
|
242
|
+
/**
|
|
243
|
+
* Returns a list of validation errors for this instance.
|
|
244
|
+
*
|
|
245
|
+
* A TextStyleSettings object may contain values that are invalid in all contexts.
|
|
246
|
+
* If this method returns any error strings, using the settings will likely result in rendering failures or runtime exceptions.
|
|
247
|
+
*
|
|
248
|
+
* This method only checks for universally invalid values. Additional domain-specific validation may be required depending on the context in which these settings are used.
|
|
249
|
+
*
|
|
250
|
+
* @returns An array of error strings describing the invalid values, or an empty array if the settings are valid.
|
|
251
|
+
*/
|
|
252
|
+
getValidationErrors(): string[];
|
|
172
253
|
}
|
|
173
254
|
//# sourceMappingURL=TextStyle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextStyle.d.ts","sourceRoot":"","sources":["../../../src/annotation/TextStyle.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"TextStyle.d.ts","sourceRoot":"","sources":["../../../src/annotation/TextStyle.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAY,aAAa,EAAE,MAAM,aAAa,CAAC;AAEtD;;EAEE;AACF,eAAO,MAAM,yBAAyB,+JAAgK,CAAC;AAEvM;;EAEE;AACF,MAAM,MAAM,wBAAwB,GAAG,OAAO,yBAAyB,CAAC,MAAM,CAAC,CAAC;AAEhF;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAAG,cAAc,GAAG,YAAY,GAAG,MAAM,CAAC;AAE7E;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,YAAY,GAAG,UAAU,CAAC;AAE5D;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG,aAAa,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,0CAA0C;IAC1C,KAAK,CAAC,EAAE,wBAAwB,CAAC;IACjC,0HAA0H;IAC1H,IAAI,CAAC,EAAE,uBAAuB,CAAC;IAC/B,4DAA4D;IAC5D,MAAM,CAAC,EAAE,cAAc,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AChG,KAAK,CAAC,YAAY,CAAC,EAAE,sBAAsB,GAAG,iBAAiB;IAItE,2DAA2D;WAC7C,UAAU,CAAC,KAAK,EAAE,sBAAsB,GAAG,sBAAsB;IAW/E,sDAAsD;WACxC,QAAQ,CAAC,KAAK,CAAC,EAAE,sBAAsB,GAAG,iBAAiB;IAIlE,MAAM,IAAI,sBAAsB;IAIvC;;;OAGG;IACI,YAAY,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO;IAMlD,WAAW,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO;IAOhD,MAAM,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO;IAYhD;;;;;;;;;OASG;IACI,mBAAmB,IAAI,MAAM,EAAE;CAgBvC"}
|
|
@@ -7,9 +7,26 @@
|
|
|
7
7
|
* @module Annotation
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
10
|
+
exports.TextStyleSettings = exports.textAnnotationFrameShapes = void 0;
|
|
11
|
+
const ColorDef_1 = require("../ColorDef");
|
|
12
|
+
/** Set of predefined shapes that can be computed and drawn around the margins of a [[TextBlock]]
|
|
13
|
+
* @beta
|
|
14
|
+
*/
|
|
15
|
+
exports.textAnnotationFrameShapes = ["none", "line", "rectangle", "circle", "equilateralTriangle", "diamond", "square", "pentagon", "hexagon", "octagon", "capsule", "roundedRectangle"];
|
|
16
|
+
;
|
|
17
|
+
function deepFreeze(obj) {
|
|
18
|
+
if (obj === null || typeof obj !== "object" || Object.isFrozen(obj))
|
|
19
|
+
return;
|
|
20
|
+
Object.getOwnPropertyNames(obj).forEach((prop) => {
|
|
21
|
+
const value = obj[prop];
|
|
22
|
+
if (value && typeof value === "object") {
|
|
23
|
+
deepFreeze(value);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
Object.freeze(obj);
|
|
27
|
+
}
|
|
11
28
|
/** A description of the formatting to be applied to a [[TextBlockComponent]].
|
|
12
|
-
* Named instances of these settings can be stored as [
|
|
29
|
+
* Named instances of these settings can be stored as [AnnotationTextStyle]($backend)s in an iModel.
|
|
13
30
|
* @note This is an immutable type. Use [[clone]] to create a modified copy.
|
|
14
31
|
* @see [[TextStyleSettingsProps]] for documentation of each of the settings.
|
|
15
32
|
* @beta
|
|
@@ -17,11 +34,11 @@ exports.TextStyle = exports.TextStyleSettings = void 0;
|
|
|
17
34
|
class TextStyleSettings {
|
|
18
35
|
/** The color of the text. */
|
|
19
36
|
color;
|
|
20
|
-
/** The name of a font stored in
|
|
37
|
+
/** The name of a font stored in an iModel, used to draw the contents of a [[TextRun]].
|
|
21
38
|
*/
|
|
22
39
|
fontName;
|
|
23
40
|
/** The height each line of text, in meters. Many other settings use the line height as the basis for computing their own values.
|
|
24
|
-
* For example, the height and offset from baseline of a subscript [[TextRun]] are
|
|
41
|
+
* For example, the height and offset from baseline of a subscript [[TextRun]] are computed as lineHeight * [[subScriptScale]] and
|
|
25
42
|
* lineHeight * [[subScriptOffsetFactor]], respectively.
|
|
26
43
|
*/
|
|
27
44
|
lineHeight;
|
|
@@ -59,7 +76,17 @@ class TextStyleSettings {
|
|
|
59
76
|
superScriptScale;
|
|
60
77
|
/** Multiplier used to compute the width of each glyph, relative to [[lineHeight]]. */
|
|
61
78
|
widthFactor;
|
|
62
|
-
/**
|
|
79
|
+
/** Properties describing appearance of leaders in a [[TextAnnotation]].
|
|
80
|
+
* Used when producing geometry for [[TextAnnotation]].
|
|
81
|
+
*/
|
|
82
|
+
leader;
|
|
83
|
+
/** The size (in meters) used to calculate the tab stops in a run.
|
|
84
|
+
* These are equally spaced from the left edge of the TextBlock. Default is 4 meters.
|
|
85
|
+
*/
|
|
86
|
+
tabInterval;
|
|
87
|
+
/** The frame settings of the [[TextAnnotation]]. */
|
|
88
|
+
frame;
|
|
89
|
+
/** A fully-populated JSON representation of the default settings. A real `fontName` must be provided before use. */
|
|
63
90
|
static defaultProps = {
|
|
64
91
|
color: "subcategory",
|
|
65
92
|
fontName: "",
|
|
@@ -75,6 +102,20 @@ class TextStyleSettings {
|
|
|
75
102
|
superScriptOffsetFactor: 0.5,
|
|
76
103
|
superScriptScale: 2 / 3,
|
|
77
104
|
widthFactor: 1,
|
|
105
|
+
leader: {
|
|
106
|
+
color: "inherit",
|
|
107
|
+
wantElbow: false,
|
|
108
|
+
elbowLength: 1.0,
|
|
109
|
+
terminatorHeightFactor: 1.0,
|
|
110
|
+
terminatorWidthFactor: 1.0,
|
|
111
|
+
},
|
|
112
|
+
tabInterval: 4,
|
|
113
|
+
frame: {
|
|
114
|
+
shape: "none",
|
|
115
|
+
fill: "none",
|
|
116
|
+
border: ColorDef_1.ColorDef.black.toJSON(),
|
|
117
|
+
borderWeight: 1,
|
|
118
|
+
},
|
|
78
119
|
};
|
|
79
120
|
/** Settings initialized to all default values. */
|
|
80
121
|
static defaults = new TextStyleSettings({});
|
|
@@ -96,11 +137,39 @@ class TextStyleSettings {
|
|
|
96
137
|
this.superScriptOffsetFactor = props.superScriptOffsetFactor ?? defaults.superScriptOffsetFactor;
|
|
97
138
|
this.superScriptScale = props.superScriptScale ?? defaults.superScriptScale;
|
|
98
139
|
this.widthFactor = props.widthFactor ?? defaults.widthFactor;
|
|
140
|
+
const leader = {
|
|
141
|
+
color: props.leader?.color ?? defaults.leader.color,
|
|
142
|
+
wantElbow: props.leader?.wantElbow ?? defaults.leader.wantElbow,
|
|
143
|
+
elbowLength: props.leader?.elbowLength ?? defaults.leader.elbowLength,
|
|
144
|
+
terminatorHeightFactor: props.leader?.terminatorHeightFactor ?? defaults.leader.terminatorHeightFactor,
|
|
145
|
+
terminatorWidthFactor: props.leader?.terminatorWidthFactor ?? defaults.leader.terminatorWidthFactor,
|
|
146
|
+
};
|
|
147
|
+
this.leader = Object.freeze(leader);
|
|
148
|
+
this.tabInterval = props.tabInterval ?? defaults.tabInterval;
|
|
149
|
+
const frame = {
|
|
150
|
+
shape: props.frame?.shape ?? defaults.frame.shape,
|
|
151
|
+
fill: props.frame?.fill ?? defaults.frame.fill,
|
|
152
|
+
border: props.frame?.border ?? defaults.frame.border,
|
|
153
|
+
borderWeight: props.frame?.borderWeight ?? defaults.frame.borderWeight,
|
|
154
|
+
};
|
|
155
|
+
// Cast to indicate to TypeScript that the frame properties are all defined
|
|
156
|
+
this.frame = Object.freeze(frame);
|
|
99
157
|
}
|
|
100
158
|
/** Create a copy of these settings, modified according to the properties defined by `alteredProps`. */
|
|
101
159
|
clone(alteredProps) {
|
|
102
160
|
return alteredProps ? new TextStyleSettings(alteredProps, this) : this;
|
|
103
161
|
}
|
|
162
|
+
/** Creates a deep copy of the `TextStyleSettingsProps`. */
|
|
163
|
+
static cloneProps(props) {
|
|
164
|
+
const copy = { ...props };
|
|
165
|
+
if (props.leader) {
|
|
166
|
+
copy.leader = { ...props.leader };
|
|
167
|
+
}
|
|
168
|
+
if (props.frame) {
|
|
169
|
+
copy.frame = { ...props.frame };
|
|
170
|
+
}
|
|
171
|
+
return copy;
|
|
172
|
+
}
|
|
104
173
|
/** Create settings from their JSON representation. */
|
|
105
174
|
static fromJSON(props) {
|
|
106
175
|
return props ? new TextStyleSettings(props) : TextStyleSettings.defaults;
|
|
@@ -108,45 +177,57 @@ class TextStyleSettings {
|
|
|
108
177
|
toJSON() {
|
|
109
178
|
return { ...this };
|
|
110
179
|
}
|
|
180
|
+
/** Compare two [[TextLeaderStyleProps]] for equality.
|
|
181
|
+
* @param other The other leader style properties to compare against.
|
|
182
|
+
* @returns true if the two leader styles are equal, false otherwise.
|
|
183
|
+
*/
|
|
184
|
+
leaderEquals(other) {
|
|
185
|
+
return this.leader.color === other.color && this.leader.wantElbow === other.wantElbow
|
|
186
|
+
&& this.leader.elbowLength === other.elbowLength && this.leader.terminatorHeightFactor === other.terminatorHeightFactor
|
|
187
|
+
&& this.leader.terminatorWidthFactor === other.terminatorWidthFactor;
|
|
188
|
+
}
|
|
189
|
+
frameEquals(other) {
|
|
190
|
+
return this.frame?.shape === other.shape
|
|
191
|
+
&& this.frame?.fill === other.fill
|
|
192
|
+
&& this.frame?.border === other.border
|
|
193
|
+
&& this.frame?.borderWeight === other.borderWeight;
|
|
194
|
+
}
|
|
111
195
|
equals(other) {
|
|
112
196
|
return this.color === other.color && this.fontName === other.fontName
|
|
113
197
|
&& this.lineHeight === other.lineHeight && this.lineSpacingFactor === other.lineSpacingFactor && this.widthFactor === other.widthFactor
|
|
114
198
|
&& this.isBold === other.isBold && this.isItalic === other.isItalic && this.isUnderlined === other.isUnderlined
|
|
115
199
|
&& this.stackedFractionType === other.stackedFractionType && this.stackedFractionScale === other.stackedFractionScale
|
|
116
200
|
&& this.subScriptOffsetFactor === other.subScriptOffsetFactor && this.subScriptScale === other.subScriptScale
|
|
117
|
-
&& this.superScriptOffsetFactor === other.superScriptOffsetFactor && this.superScriptScale === other.superScriptScale
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
Object.freeze(TextStyleSettings.defaultProps);
|
|
122
|
-
Object.freeze(TextStyleSettings.defaults);
|
|
123
|
-
/** A named, immutable [[TextStyleSettings]] stored in a [Workspace]($backend).
|
|
124
|
-
* @see [[TextBlockComponent.styleName]] to define the text style for a component of a [[TextBlock]].
|
|
125
|
-
* @note This is an immutable type. Use [[clone]] to create a modified copy.
|
|
126
|
-
* @beta
|
|
127
|
-
*/
|
|
128
|
-
class TextStyle {
|
|
129
|
-
name;
|
|
130
|
-
settings;
|
|
131
|
-
constructor(name, settings) {
|
|
132
|
-
this.name = name;
|
|
133
|
-
this.settings = settings;
|
|
134
|
-
}
|
|
135
|
-
/** Create a style from its JSON representation. */
|
|
136
|
-
static fromJSON(json) {
|
|
137
|
-
return TextStyle.create(json.name, TextStyleSettings.fromJSON(json.settings));
|
|
138
|
-
}
|
|
139
|
-
/** Create a new style. */
|
|
140
|
-
static create(name, settings) {
|
|
141
|
-
return new TextStyle(name, settings);
|
|
142
|
-
}
|
|
143
|
-
/** Create a copy of this style with the same name, and settings modified according to the properties defined by `alteredSettings`. */
|
|
144
|
-
clone(alteredSettings) {
|
|
145
|
-
return TextStyle.create(this.name, this.settings.clone(alteredSettings));
|
|
201
|
+
&& this.superScriptOffsetFactor === other.superScriptOffsetFactor && this.superScriptScale === other.superScriptScale
|
|
202
|
+
&& this.tabInterval === other.tabInterval
|
|
203
|
+
&& this.leaderEquals(other.leader)
|
|
204
|
+
&& this.frameEquals(other.frame);
|
|
146
205
|
}
|
|
147
|
-
|
|
148
|
-
|
|
206
|
+
/**
|
|
207
|
+
* Returns a list of validation errors for this instance.
|
|
208
|
+
*
|
|
209
|
+
* A TextStyleSettings object may contain values that are invalid in all contexts.
|
|
210
|
+
* If this method returns any error strings, using the settings will likely result in rendering failures or runtime exceptions.
|
|
211
|
+
*
|
|
212
|
+
* This method only checks for universally invalid values. Additional domain-specific validation may be required depending on the context in which these settings are used.
|
|
213
|
+
*
|
|
214
|
+
* @returns An array of error strings describing the invalid values, or an empty array if the settings are valid.
|
|
215
|
+
*/
|
|
216
|
+
getValidationErrors() {
|
|
217
|
+
const errorMessages = [];
|
|
218
|
+
if (this.fontName.trim() === "") {
|
|
219
|
+
errorMessages.push("fontName must be provided");
|
|
220
|
+
}
|
|
221
|
+
if (this.lineHeight <= 0) {
|
|
222
|
+
errorMessages.push("lineHeight must be greater than 0");
|
|
223
|
+
}
|
|
224
|
+
if (this.stackedFractionScale <= 0) {
|
|
225
|
+
errorMessages.push("stackedFractionScale must be greater than 0");
|
|
226
|
+
}
|
|
227
|
+
return errorMessages;
|
|
149
228
|
}
|
|
150
229
|
}
|
|
151
|
-
exports.
|
|
230
|
+
exports.TextStyleSettings = TextStyleSettings;
|
|
231
|
+
deepFreeze(TextStyleSettings.defaultProps);
|
|
232
|
+
deepFreeze(TextStyleSettings.defaults);
|
|
152
233
|
//# sourceMappingURL=TextStyle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextStyle.js","sourceRoot":"","sources":["../../../src/annotation/TextStyle.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;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;IACJ,IAAI,CAAS;IACb,QAAQ,CAAoB;IAE5C,YAAoB,IAAY,EAAE,QAA2B;QAC3D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,mDAAmD;IAC5C,MAAM,CAAC,QAAQ,CAAC,IAAoB;QACzC,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAChF,CAAC;IAED,0BAA0B;IACnB,MAAM,CAAC,MAAM,CAAC,IAAY,EAAE,QAA2B;QAC5D,OAAO,IAAI,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED,sIAAsI;IAC/H,KAAK,CAAC,eAAuC;QAClD,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;IAC3E,CAAC;IAEM,MAAM,CAAC,KAAgB;QAC5B,OAAO,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1E,CAAC;CACF;AA3BD,8BA2BC","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 Annotation\n */\n\nimport { ColorDefProps } from \"../ColorDef\";\n\n/** Specifies how to separate the numerator and denominator of a [[FractionRun]], by either a horizontal or diagonal bar.\n * @see [[TextStyleSettingsProps.stackedFractionType]] and [[TextStyleSettings.stackedFractionType]].\n * @beta\n */\nexport type StackedFractionType = \"horizontal\" | \"diagonal\";\n\n/** Describes the color in which to draw the text in a [[TextRun]].\n * \"subcategory\" indicates that the text should be drawn using the color of the [SubCategory]($backend) specified by the [GeometryStream]($docs/learning/common/GeometryStream.md) hosting the\n * text.\n * @beta\n */\nexport type TextStyleColor = ColorDefProps | \"subcategory\";\n\n/** Serves both as the JSON representation of a [[TextStyleSettings]], and a way for a [[TextBlockComponent]] to selectively override aspects of a [[TextStyle]]'s properties.\n * @beta\n */\nexport interface TextStyleSettingsProps {\n /** The color of the text.\n * Default: \"subcategory\".\n */\n color?: TextStyleColor;\n /** The name of a font stored in a [Workspace]($backend), used to draw the contents of a [[TextRun]].\n * Default: \"\" (an invalid font name).\n */\n fontName?: string;\n /** The height each line of text, in meters. Many other settings use the line height as the basis for computing their own values.\n * For example, the height and offset from baseline of a subscript [[TextRun]] are compuated as lineHeight * [[subScriptScale]] and\n * lineHeight * [[subScriptOffsetFactor]], respectively.\n * Default: 1.0. */\n lineHeight?: number;\n /** Multiplier used to compute the vertical distance between two lines of text.\n * The distance is computed in meters as lineSpacingFactor * [[lineHeight]].\n * Default: 0.5.\n */\n lineSpacingFactor?: number;\n /** Specifies whether the content of a [[TextRun]] should be rendered **bold**.\n * Default: false.\n */\n isBold?: boolean;\n /** Specifies whether the content of a [[TextRun]] should be rendered in *italics*.\n * Default: false.\n */\n isItalic?: boolean;\n /** Specifies whether the content of a [[TextRun]] should be underlined.\n * Default: false.\n */\n isUnderlined?: boolean;\n /** Multiplier used to compute the height of both the numerator and denominator of a [[FractionRun]].\n * The height is computed in meters as stackedFractionScale * [[lineHeight]].\n * Default: 0.7.\n */\n stackedFractionScale?: number;\n /** Specifies how to separate the numerator and denominator of a [[FractionRun]].\n * Default: \"horizontal\".\n */\n stackedFractionType?: StackedFractionType;\n /** Multiplier used to compute the vertical offset from the baseline for a subscript [[TextRun]].\n * The offset is computed in meters as subScriptOffsetFactor * [[lineHeight]].\n * Default: -0.15.\n */\n subScriptOffsetFactor?: number;\n /** Multiplier used to compute the height of a subscript [[TextRun]].\n * The height is computed as subScriptScale * [[lineHeight]].\n * Default: 2/3\n */\n subScriptScale?: number;\n /** Multiplier used to compute the vertical offset from the baseline for a super [[TextRun]].\n * The offset is computed in meters as superScriptOffsetFactor * [[lineHeight]].\n * Default: -0.5.\n */\n superScriptOffsetFactor?: number;\n /** Multiplier used to compute the height of a superscript [[TextRun]].\n * The height is computed as superScriptScale * [[lineHeight]].\n * Default: 2/3\n */\n superScriptScale?: number;\n /** A scale applied to the width of each glyph.\n * Default: 1.0\n */\n widthFactor?: number;\n}\n\n/** A description of the formatting to be applied to a [[TextBlockComponent]].\n * Named instances of these settings can be stored as [[TextStyle]]s in a [Workspace]($backend).\n * @note This is an immutable type. Use [[clone]] to create a modified copy.\n * @see [[TextStyleSettingsProps]] for documentation of each of the settings.\n * @beta\n */\nexport class TextStyleSettings {\n /** The color of the text. */\n public readonly color: TextStyleColor;\n /** The name of a font stored in a [Workspace]($backend), used to draw the contents of a [[TextRun]].\n */\n public readonly fontName: string;\n /** The height each line of text, in meters. Many other settings use the line height as the basis for computing their own values.\n * For example, the height and offset from baseline of a subscript [[TextRun]] are compuated as lineHeight * [[subScriptScale]] and\n * lineHeight * [[subScriptOffsetFactor]], respectively.\n */\n public readonly lineHeight: number;\n /** Multiplier used to compute the vertical distance between two lines of text.\n * The distance is computed in meters as lineSpacingFactor * [[lineHeight]].\n */\n public readonly lineSpacingFactor: number;\n /** Specifies whether the content of a [[TextRun]] should be rendered **bold**. */\n public readonly isBold: boolean;\n /** Specifies whether the content of a [[TextRun]] should be rendered in *italics*. */\n public readonly isItalic: boolean;\n /** Specifies whether the content of a [[TextRun]] should be underlined. */\n public readonly isUnderlined: boolean;\n /** Multiplier used to compute the height of both the numerator and denominator of a [[FractionRun]].\n * The height is computed in meters as stackedFractionScale * [[lineHeight]].\n */\n public readonly stackedFractionScale: number;\n /** Specifies how to separate the numerator and denominator of a [[FractionRun]]. */\n public readonly stackedFractionType: StackedFractionType;\n /** Multiplier used to compute the vertical offset from the baseline for a subscript [[TextRun]].\n * The offset is computed in meters as subScriptOffsetFactor * [[lineHeight]].\n */\n public readonly subScriptOffsetFactor: number;\n /** Multiplier used to compute the height of a subscript [[TextRun]].\n * The height is computed as subScriptScale * [[lineHeight]].\n */\n public readonly subScriptScale: number;\n /** Multiplier used to compute the vertical offset from the baseline for a super [[TextRun]].\n * The offset is computed in meters as superScriptOffsetFactor * [[lineHeight]].\n */\n public readonly superScriptOffsetFactor: number;\n /** Multiplier used to compute the height of a superscript [[TextRun]].\n * The height is computed as superScriptScale * [[lineHeight]].\n */\n public readonly superScriptScale: number;\n /** Multiplier used to compute the width of each glyph, relative to [[lineHeight]]. */\n public readonly widthFactor: number;\n\n /** A fully-populated JSON representation of the default settings. */\n public static defaultProps: Readonly<Required<TextStyleSettingsProps>> = {\n color: \"subcategory\",\n fontName: \"\",\n lineHeight: 1,\n lineSpacingFactor: 0.5,\n isBold: false,\n isItalic: false,\n isUnderlined: false,\n stackedFractionScale: 0.7,\n stackedFractionType: \"horizontal\",\n subScriptOffsetFactor: -0.15,\n subScriptScale: 2 / 3,\n superScriptOffsetFactor: 0.5,\n superScriptScale: 2 / 3,\n widthFactor: 1,\n };\n\n /** Settings initialized to all default values. */\n public static defaults: TextStyleSettings = new TextStyleSettings({ });\n\n private constructor(props: TextStyleSettingsProps, defaults?: Required<TextStyleSettingsProps>) {\n if (!defaults) {\n defaults = TextStyleSettings.defaultProps;\n }\n\n this.color = props.color ?? defaults.color;\n this.fontName = props.fontName ?? defaults.fontName;\n this.lineHeight = props.lineHeight ?? defaults.lineHeight;\n this.lineSpacingFactor = props.lineSpacingFactor ?? defaults.lineSpacingFactor;\n this.isBold = props.isBold ?? defaults.isBold;\n this.isItalic = props.isItalic ?? defaults.isItalic;\n this.isUnderlined = props.isUnderlined ?? defaults.isUnderlined;\n this.stackedFractionScale = props.stackedFractionScale ?? defaults.stackedFractionScale;\n this.stackedFractionType = props.stackedFractionType ?? defaults.stackedFractionType;\n this.subScriptOffsetFactor = props.subScriptOffsetFactor ?? defaults.subScriptOffsetFactor;\n this.subScriptScale = props.subScriptScale ?? defaults.subScriptScale;\n this.superScriptOffsetFactor = props.superScriptOffsetFactor ?? defaults.superScriptOffsetFactor;\n this.superScriptScale = props.superScriptScale ?? defaults.superScriptScale;\n this.widthFactor = props.widthFactor ?? defaults.widthFactor;\n }\n\n /** Create a copy of these settings, modified according to the properties defined by `alteredProps`. */\n public clone(alteredProps?: TextStyleSettingsProps): TextStyleSettings {\n return alteredProps ? new TextStyleSettings(alteredProps, this) : this;\n }\n\n /** Create settings from their JSON representation. */\n public static fromJSON(props?: TextStyleSettingsProps): TextStyleSettings {\n return props ? new TextStyleSettings(props) : TextStyleSettings.defaults;\n }\n\n public toJSON(): TextStyleSettingsProps {\n return { ...this };\n }\n\n public equals(other: TextStyleSettings): boolean {\n return this.color === other.color && this.fontName === other.fontName\n && this.lineHeight === other.lineHeight && this.lineSpacingFactor === other.lineSpacingFactor && this.widthFactor === other.widthFactor\n && this.isBold === other.isBold && this.isItalic === other.isItalic && this.isUnderlined === other.isUnderlined\n && this.stackedFractionType === other.stackedFractionType && this.stackedFractionScale === other.stackedFractionScale\n && this.subScriptOffsetFactor === other.subScriptOffsetFactor && this.subScriptScale === other.subScriptScale\n && this.superScriptOffsetFactor === other.superScriptOffsetFactor && this.superScriptScale === other.superScriptScale;\n }\n}\n\nObject.freeze(TextStyleSettings.defaultProps);\nObject.freeze(TextStyleSettings.defaults);\n\n/** The JSON representation of a [[TextStyle]].\n * @beta\n */\nexport interface TextStyleProps {\n /** The name of the style. */\n name: string;\n /** The settings defined for the style. Any omitted properties will use their default values, as described by [[TextStyleSettingsProps]]. */\n settings?: TextStyleSettingsProps;\n}\n\n/** A named, immutable [[TextStyleSettings]] stored in a [Workspace]($backend).\n * @see [[TextBlockComponent.styleName]] to define the text style for a component of a [[TextBlock]].\n * @note This is an immutable type. Use [[clone]] to create a modified copy.\n * @beta\n */\nexport class TextStyle {\n public readonly name: string;\n public readonly settings: TextStyleSettings;\n\n private constructor(name: string, settings: TextStyleSettings) {\n this.name = name;\n this.settings = settings;\n }\n\n /** Create a style from its JSON representation. */\n public static fromJSON(json: TextStyleProps): TextStyle {\n return TextStyle.create(json.name, TextStyleSettings.fromJSON(json.settings));\n }\n\n /** Create a new style. */\n public static create(name: string, settings: TextStyleSettings): TextStyle {\n return new TextStyle(name, settings);\n }\n\n /** Create a copy of this style with the same name, and settings modified according to the properties defined by `alteredSettings`. */\n public clone(alteredSettings: TextStyleSettingsProps): TextStyle {\n return TextStyle.create(this.name, this.settings.clone(alteredSettings));\n }\n\n public equals(other: TextStyle): boolean {\n return this.name === other.name && this.settings.equals(other.settings);\n }\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"TextStyle.js","sourceRoot":"","sources":["../../../src/annotation/TextStyle.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,0CAAsD;AAEtD;;EAEE;AACW,QAAA,yBAAyB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,qBAAqB,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,kBAAkB,CAAU,CAAC;AA2CtM,CAAC;AAuHF,SAAS,UAAU,CAAI,GAAM;IAC3B,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QACjE,OAAO;IACT,MAAM,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC/C,MAAM,KAAK,GAAI,GAAW,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACvC,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,MAAM,CAAC,GAAG,CA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,CAAC,MAAM,CAAC;eAC/B,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;IAED;;;;;;;;;OASG;IACI,mBAAmB;QACxB,MAAM,aAAa,GAAa,EAAE,CAAC;QACnC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAChC,aAAa,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QAClD,CAAC;QAED,IAAI,IAAI,CAAC,UAAU,IAAI,CAAC,EAAE,CAAC;YACzB,aAAa,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;QAC1D,CAAC;QAED,IAAI,IAAI,CAAC,oBAAoB,IAAI,CAAC,EAAE,CAAC;YACnC,aAAa,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;QACpE,CAAC;QAED,OAAO,aAAa,CAAC;IACvB,CAAC;;AAjNH,8CAkNC;AAED,UAAU,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;AAC3C,UAAU,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Annotation\n */\n\nimport { DeepReadonlyObject, DeepRequiredObject } from \"@itwin/core-bentley\";\nimport { ColorDef, ColorDefProps } from \"../ColorDef\";\n\n/** Set of predefined shapes that can be computed and drawn around the margins of a [[TextBlock]]\n * @beta\n*/\nexport const textAnnotationFrameShapes = [\"none\", \"line\", \"rectangle\", \"circle\", \"equilateralTriangle\", \"diamond\", \"square\", \"pentagon\", \"hexagon\", \"octagon\", \"capsule\", \"roundedRectangle\"] as const;\n\n/** Describes a predefined shape that can be computed and drawn around the margins of a [[TextBlock]]\n * @beta\n*/\nexport type TextAnnotationFrameShape = typeof textAnnotationFrameShapes[number];\n\n/**\n * Describes what color to use when filling the frame around a [[TextBlock]].\n * If `background` is specified, [[GeometryParams.BackgroundFill]] will be set to `BackgroundFill.Outline`.\n * If `none` is specified, no fill will be applied.\n * @beta\n */\nexport type TextAnnotationFillColor = TextStyleColor | \"background\" | \"none\";\n\n/** Specifies how to separate the numerator and denominator of a [[FractionRun]], by either a horizontal or diagonal bar.\n * @see [[TextStyleSettingsProps.stackedFractionType]] and [[TextStyleSettings.stackedFractionType]].\n * @beta\n */\nexport type StackedFractionType = \"horizontal\" | \"diagonal\";\n\n/** Describes the color in which to draw the text in a [[TextRun]].\n * \"subcategory\" indicates that the text should be drawn using the color of the [SubCategory]($backend) specified by the [GeometryStream]($docs/learning/common/GeometryStream.md) hosting the\n * text.\n * @beta\n */\nexport type TextStyleColor = ColorDefProps | \"subcategory\";\n\n/**\n * Describes how to draw the frame around a [[TextAnnotation]].\n * The frame can be a simple line, a filled shape, or both.\n * If only a subset of properties are specified, the others will be set to their default value.\n * @beta\n */\nexport interface TextFrameStyleProps {\n /** Shape of the frame. Default: \"none\" */\n shape?: TextAnnotationFrameShape;\n /** The color to fill the shape of the text frame. This fill is applied using [[FillDisplay.Blanking]]. Default: \"none\" */\n fill?: TextAnnotationFillColor;\n /** The color of the text frame's outline. Default: black */\n border?: TextStyleColor;\n /** This will be used to set the [[GeometryParams.weight]] property of the frame (in pixels). Default: 1px */\n borderWeight?: number;\n};\n\n/** Properties describing the appearance of [[TextAnnotationLeader]] in a [[TextAnnotation]].\n * Used when producing geometry for [[TextAnnotation]].\n * @beta\n */\nexport interface TextLeaderStyleProps {\n /** The color of the leader.\n * If `inherit` is specified, the [[TextAnnotationLeader]] will use the color specified in the parent [[TextStyleSettings]]`.\n * Default: \"inherit\".\n */\n color?: TextStyleColor | \"inherit\";\n /** Whether to use an elbow in the leader.\n * Default: false\n */\n wantElbow?: boolean;\n /** Multiplier used to compute length of the elbow in the leader.\n * The elbowLength is computed in meters as elbowLength * [[lineHeight]].\n * Default: 1.0\n */\n elbowLength?: number;\n /** Multiplier to compute height of the leader terminator.\n * The terminator height is computed in meters as terminatorHeight * [[lineHeight]].\n * Default: 1.0\n */\n terminatorHeightFactor?: number;\n /** Multiplier to compute width of the leader terminator.\n * The terminator width is computed in meters as terminatorWidth * [[lineHeight]].\n * Default: 1.0\n */\n terminatorWidthFactor?: number;\n}\n\n/** Serves both as the JSON representation of a [[TextStyleSettings]], and a way for a [[TextBlockComponent]] to selectively override aspects of a [AnnotationTextStyle]($backend)'s properties.\n * @beta\n */\nexport interface TextStyleSettingsProps {\n /** The color of the text.\n * Default: \"subcategory\".\n */\n color?: TextStyleColor;\n /** The name of a font stored in an iModel, used to draw the contents of a [[TextRun]].\n * Default: \"\" (an invalid font name).\n */\n fontName?: string;\n /** The height each line of text, in meters. Many other settings use the line height as the basis for computing their own values.\n * For example, the height and offset from baseline of a subscript [[TextRun]] are computed as lineHeight * [[subScriptScale]] and\n * lineHeight * [[subScriptOffsetFactor]], respectively.\n * Default: 1.0. */\n lineHeight?: number;\n /** Multiplier used to compute the vertical distance between two lines of text.\n * The distance is computed in meters as lineSpacingFactor * [[lineHeight]].\n * Default: 0.5.\n */\n lineSpacingFactor?: number;\n /** Specifies whether the content of a [[TextRun]] should be rendered **bold**.\n * Default: false.\n */\n isBold?: boolean;\n /** Specifies whether the content of a [[TextRun]] should be rendered in *italics*.\n * Default: false.\n */\n isItalic?: boolean;\n /** Specifies whether the content of a [[TextRun]] should be underlined.\n * Default: false.\n */\n isUnderlined?: boolean;\n /** Multiplier used to compute the height of both the numerator and denominator of a [[FractionRun]].\n * The height is computed in meters as stackedFractionScale * [[lineHeight]].\n * Default: 0.7.\n */\n stackedFractionScale?: number;\n /** Specifies how to separate the numerator and denominator of a [[FractionRun]].\n * Default: \"horizontal\".\n */\n stackedFractionType?: StackedFractionType;\n /** Multiplier used to compute the vertical offset from the baseline for a subscript [[TextRun]].\n * The offset is computed in meters as subScriptOffsetFactor * [[lineHeight]].\n * Default: -0.15.\n */\n subScriptOffsetFactor?: number;\n /** Multiplier used to compute the height of a subscript [[TextRun]].\n * The height is computed as subScriptScale * [[lineHeight]].\n * Default: 2/3\n */\n subScriptScale?: number;\n /** Multiplier used to compute the vertical offset from the baseline for a super [[TextRun]].\n * The offset is computed in meters as superScriptOffsetFactor * [[lineHeight]].\n * Default: -0.5.\n */\n superScriptOffsetFactor?: number;\n /** Multiplier used to compute the height of a superscript [[TextRun]].\n * The height is computed as superScriptScale * [[lineHeight]].\n * Default: 2/3\n */\n superScriptScale?: number;\n /** A scale applied to the width of each glyph.\n * Default: 1.0\n */\n widthFactor?: number;\n\n /** Properties describing appearance of leaders in a [[TextAnnotation]]\n * Used when producing geometry for [[TextAnnotation]]\n * Default: {color:\"subcategory\", wantElbow:\"false\",elbowLength:1, terminatorWidthFactor:1, terminatorHeightFactor:1}.\n */\n leader?: TextLeaderStyleProps;\n /** The size (in meters) used to calculate the tab stops in a run.\n * These are equally spaced from the left edge of the TextBlock.\n * Default: 4 meters.\n */\n tabInterval?: number;\n /**\n * A description of the frame around the text annotation.\n * Used when producing geometry for [[TextAnnotation]]s.\n * Default: {shape: \"none\", fill: \"none\", border: black, borderWeight: 1} for no frame.\n */\n frame?: TextFrameStyleProps;\n}\n\nfunction deepFreeze<T>(obj: T) {\n if (obj === null || typeof obj !== \"object\" || Object.isFrozen(obj))\n return;\n Object.getOwnPropertyNames(obj).forEach((prop) => {\n const value = (obj as any)[prop];\n if (value && typeof value === \"object\") {\n deepFreeze(value);\n }\n });\n Object.freeze(obj);\n}\n\n/** A description of the formatting to be applied to a [[TextBlockComponent]].\n * Named instances of these settings can be stored as [AnnotationTextStyle]($backend)s in an iModel.\n * @note This is an immutable type. Use [[clone]] to create a modified copy.\n * @see [[TextStyleSettingsProps]] for documentation of each of the settings.\n * @beta\n */\nexport class TextStyleSettings {\n /** The color of the text. */\n public readonly color: TextStyleColor;\n /** The name of a font stored in an iModel, used to draw the contents of a [[TextRun]].\n */\n public readonly fontName: string;\n /** The height each line of text, in meters. Many other settings use the line height as the basis for computing their own values.\n * For example, the height and offset from baseline of a subscript [[TextRun]] are computed as lineHeight * [[subScriptScale]] and\n * lineHeight * [[subScriptOffsetFactor]], respectively.\n */\n public readonly lineHeight: number;\n /** Multiplier used to compute the vertical distance between two lines of text.\n * The distance is computed in meters as lineSpacingFactor * [[lineHeight]].\n */\n public readonly lineSpacingFactor: number;\n /** Specifies whether the content of a [[TextRun]] should be rendered **bold**. */\n public readonly isBold: boolean;\n /** Specifies whether the content of a [[TextRun]] should be rendered in *italics*. */\n public readonly isItalic: boolean;\n /** Specifies whether the content of a [[TextRun]] should be underlined. */\n public readonly isUnderlined: boolean;\n /** Multiplier used to compute the height of both the numerator and denominator of a [[FractionRun]].\n * The height is computed in meters as stackedFractionScale * [[lineHeight]].\n */\n public readonly stackedFractionScale: number;\n /** Specifies how to separate the numerator and denominator of a [[FractionRun]]. */\n public readonly stackedFractionType: StackedFractionType;\n /** Multiplier used to compute the vertical offset from the baseline for a subscript [[TextRun]].\n * The offset is computed in meters as subScriptOffsetFactor * [[lineHeight]].\n */\n public readonly subScriptOffsetFactor: number;\n /** Multiplier used to compute the height of a subscript [[TextRun]].\n * The height is computed as subScriptScale * [[lineHeight]].\n */\n public readonly subScriptScale: number;\n /** Multiplier used to compute the vertical offset from the baseline for a super [[TextRun]].\n * The offset is computed in meters as superScriptOffsetFactor * [[lineHeight]].\n */\n public readonly superScriptOffsetFactor: number;\n /** Multiplier used to compute the height of a superscript [[TextRun]].\n * The height is computed as superScriptScale * [[lineHeight]].\n */\n public readonly superScriptScale: number;\n /** Multiplier used to compute the width of each glyph, relative to [[lineHeight]]. */\n public readonly widthFactor: number;\n /** Properties describing appearance of leaders in a [[TextAnnotation]].\n * Used when producing geometry for [[TextAnnotation]].\n */\n public readonly leader: Readonly<Required<TextLeaderStyleProps>>;\n /** The size (in meters) used to calculate the tab stops in a run.\n * These are equally spaced from the left edge of the TextBlock. Default is 4 meters.\n */\n public readonly tabInterval: number;\n /** The frame settings of the [[TextAnnotation]]. */\n public readonly frame: Readonly<Required<TextFrameStyleProps>>;\n\n /** A fully-populated JSON representation of the default settings. A real `fontName` must be provided before use. */\n public static defaultProps: DeepReadonlyObject<DeepRequiredObject<TextStyleSettingsProps>> = {\n color: \"subcategory\",\n fontName: \"\",\n lineHeight: 1,\n lineSpacingFactor: 0.5,\n isBold: false,\n isItalic: false,\n isUnderlined: false,\n stackedFractionScale: 0.7,\n stackedFractionType: \"horizontal\",\n subScriptOffsetFactor: -0.15,\n subScriptScale: 2 / 3,\n superScriptOffsetFactor: 0.5,\n superScriptScale: 2 / 3,\n widthFactor: 1,\n leader: {\n color: \"inherit\",\n wantElbow: false,\n elbowLength: 1.0,\n terminatorHeightFactor: 1.0,\n terminatorWidthFactor: 1.0,\n },\n tabInterval: 4,\n frame: {\n shape: \"none\",\n fill: \"none\",\n border: ColorDef.black.toJSON(),\n borderWeight: 1,\n },\n };\n\n /** Settings initialized to all default values. */\n public static defaults: TextStyleSettings = new TextStyleSettings({});\n\n private constructor(props: TextStyleSettingsProps, defaults?: Required<TextStyleSettingsProps>) {\n if (!defaults) {\n defaults = TextStyleSettings.defaultProps;\n }\n\n this.color = props.color ?? defaults.color;\n this.fontName = props.fontName ?? defaults.fontName;\n this.lineHeight = props.lineHeight ?? defaults.lineHeight;\n this.lineSpacingFactor = props.lineSpacingFactor ?? defaults.lineSpacingFactor;\n this.isBold = props.isBold ?? defaults.isBold;\n this.isItalic = props.isItalic ?? defaults.isItalic;\n this.isUnderlined = props.isUnderlined ?? defaults.isUnderlined;\n this.stackedFractionScale = props.stackedFractionScale ?? defaults.stackedFractionScale;\n this.stackedFractionType = props.stackedFractionType ?? defaults.stackedFractionType;\n this.subScriptOffsetFactor = props.subScriptOffsetFactor ?? defaults.subScriptOffsetFactor;\n this.subScriptScale = props.subScriptScale ?? defaults.subScriptScale;\n this.superScriptOffsetFactor = props.superScriptOffsetFactor ?? defaults.superScriptOffsetFactor;\n this.superScriptScale = props.superScriptScale ?? defaults.superScriptScale;\n this.widthFactor = props.widthFactor ?? defaults.widthFactor;\n const leader = {\n color: props.leader?.color ?? defaults.leader.color,\n wantElbow: props.leader?.wantElbow ?? defaults.leader.wantElbow,\n elbowLength: props.leader?.elbowLength ?? defaults.leader.elbowLength,\n terminatorHeightFactor: props.leader?.terminatorHeightFactor ?? defaults.leader.terminatorHeightFactor,\n terminatorWidthFactor: props.leader?.terminatorWidthFactor ?? defaults.leader.terminatorWidthFactor,\n }\n this.leader = Object.freeze(leader) as Readonly<Required<TextLeaderStyleProps>>;\n this.tabInterval = props.tabInterval ?? defaults.tabInterval;\n const frame = {\n shape: props.frame?.shape ?? defaults.frame.shape,\n fill: props.frame?.fill ?? defaults.frame.fill,\n border: props.frame?.border ?? defaults.frame.border,\n borderWeight: props.frame?.borderWeight ?? defaults.frame.borderWeight,\n };\n // Cast to indicate to TypeScript that the frame properties are all defined\n this.frame = Object.freeze(frame) as Readonly<Required<TextFrameStyleProps>>;\n }\n\n /** Create a copy of these settings, modified according to the properties defined by `alteredProps`. */\n public clone(alteredProps?: TextStyleSettingsProps): TextStyleSettings {\n return alteredProps ? new TextStyleSettings(alteredProps, this) : this;\n }\n\n /** Creates a deep copy of the `TextStyleSettingsProps`. */\n public static cloneProps(props: TextStyleSettingsProps): TextStyleSettingsProps {\n const copy = { ...props };\n if (props.leader) {\n copy.leader = { ...props.leader };\n }\n if (props.frame) {\n copy.frame = { ...props.frame };\n }\n return copy;\n }\n\n /** Create settings from their JSON representation. */\n public static fromJSON(props?: TextStyleSettingsProps): TextStyleSettings {\n return props ? new TextStyleSettings(props) : TextStyleSettings.defaults;\n }\n\n public toJSON(): TextStyleSettingsProps {\n return { ...this };\n }\n\n /** Compare two [[TextLeaderStyleProps]] for equality.\n * @param other The other leader style properties to compare against.\n * @returns true if the two leader styles are equal, false otherwise.\n */\n public leaderEquals(other: TextLeaderStyleProps): boolean {\n return this.leader.color === other.color && this.leader.wantElbow === other.wantElbow\n && this.leader.elbowLength === other.elbowLength && this.leader.terminatorHeightFactor === other.terminatorHeightFactor\n && this.leader.terminatorWidthFactor === other.terminatorWidthFactor;\n }\n\n public frameEquals(other: TextFrameStyleProps): boolean {\n return this.frame?.shape === other.shape\n && this.frame?.fill === other.fill\n && this.frame?.border === other.border\n && this.frame?.borderWeight === other.borderWeight;\n }\n\n public equals(other: TextStyleSettings): boolean {\n return this.color === other.color && this.fontName === other.fontName\n && this.lineHeight === other.lineHeight && this.lineSpacingFactor === other.lineSpacingFactor && this.widthFactor === other.widthFactor\n && this.isBold === other.isBold && this.isItalic === other.isItalic && this.isUnderlined === other.isUnderlined\n && this.stackedFractionType === other.stackedFractionType && this.stackedFractionScale === other.stackedFractionScale\n && this.subScriptOffsetFactor === other.subScriptOffsetFactor && this.subScriptScale === other.subScriptScale\n && this.superScriptOffsetFactor === other.superScriptOffsetFactor && this.superScriptScale === other.superScriptScale\n && this.tabInterval === other.tabInterval\n && this.leaderEquals(other.leader)\n && this.frameEquals(other.frame)\n }\n\n /**\n * Returns a list of validation errors for this instance.\n *\n * A TextStyleSettings object may contain values that are invalid in all contexts.\n * If this method returns any error strings, using the settings will likely result in rendering failures or runtime exceptions.\n *\n * This method only checks for universally invalid values. Additional domain-specific validation may be required depending on the context in which these settings are used.\n *\n * @returns An array of error strings describing the invalid values, or an empty array if the settings are valid.\n */\n public getValidationErrors(): string[] {\n const errorMessages: string[] = [];\n if (this.fontName.trim() === \"\") {\n errorMessages.push(\"fontName must be provided\");\n }\n\n if (this.lineHeight <= 0) {\n errorMessages.push(\"lineHeight must be greater than 0\");\n }\n\n if (this.stackedFractionScale <= 0) {\n errorMessages.push(\"stackedFractionScale must be greater than 0\");\n }\n\n return errorMessages;\n }\n}\n\ndeepFreeze(TextStyleSettings.defaultProps);\ndeepFreeze(TextStyleSettings.defaults);"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Geometry
|
|
3
3
|
*/
|
|
4
|
+
import { Transform } from "@itwin/core-geometry";
|
|
4
5
|
/** An affine transformation with an additional Z Offset.
|
|
5
6
|
* The equations are:
|
|
6
7
|
* given a = scale * cos(rotation) and b = scale * sin(rotation)
|
|
@@ -53,6 +54,9 @@ export declare class Helmert2DWithZOffset implements Helmert2DWithZOffsetProps {
|
|
|
53
54
|
/** Compares two Helmert2DWithZOffset objects applying a minuscule tolerance.
|
|
54
55
|
* @public */
|
|
55
56
|
equals(other: Helmert2DWithZOffset): boolean;
|
|
57
|
+
/** Convert Helmert2DWithZOffset object into Transfrom object
|
|
58
|
+
* @public */
|
|
59
|
+
convertHelmertToTransform(): Transform;
|
|
56
60
|
}
|
|
57
61
|
/** Additional Transform definition
|
|
58
62
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdditionalTransform.d.ts","sourceRoot":"","sources":["../../../src/geometry/AdditionalTransform.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"AdditionalTransform.d.ts","sourceRoot":"","sources":["../../../src/geometry/AdditionalTransform.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAwC,SAAS,EAAY,MAAM,sBAAsB,CAAC;AAEjG;;;;;;;;GAQG;AACH,MAAM,WAAW,yBAAyB;IACxC,6BAA6B;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,6BAA6B;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,wCAAwC;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;GASG;AACH,qBAAa,oBAAqB,YAAW,yBAAyB;IACpE,6BAA6B;IACtB,YAAY,EAAG,MAAM,CAAC;IAC7B,6BAA6B;IACtB,YAAY,EAAG,MAAM,CAAC;IAC7B,wCAAwC;IACjC,YAAY,EAAG,MAAM,CAAC;IAC7B,oEAAoE;IAC7D,MAAM,EAAG,MAAM,CAAC;IACvB,iFAAiF;IAC1E,KAAK,EAAG,MAAM,CAAC;gBAEV,IAAI,CAAC,EAAE,yBAAyB;IAU5C;iBACa;WACC,QAAQ,CAAC,IAAI,EAAE,yBAAyB,GAAG,oBAAoB;IAI7E;iBACa;IACN,MAAM,IAAI,yBAAyB;IAI1C;kBACc;IACP,MAAM,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO;IAQnD;iBACa;IACN,yBAAyB,IAAI,SAAS;CAe9C;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,gFAAgF;IAChF,oBAAoB,CAAC,EAAE,yBAAyB,CAAC;CAClD;AAED;;;;;EAKE;AACF,qBAAa,mBAAoB,YAAW,wBAAwB;IAElE,gFAAgF;IAChF,SAAgB,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;gBAEzC,IAAI,CAAC,EAAE,wBAAwB;IAKlD;iBACa;WACC,QAAQ,CAAC,IAAI,EAAE,wBAAwB,GAAG,mBAAmB;IAI3E;iBACa;IACN,MAAM,IAAI,wBAAwB;IAIzC;kBACc;IACP,MAAM,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO;CASnD"}
|
|
@@ -59,6 +59,15 @@ class Helmert2DWithZOffset {
|
|
|
59
59
|
Math.abs(this.rotDeg - other.rotDeg) < core_geometry_1.Geometry.smallAngleDegrees &&
|
|
60
60
|
Math.abs(this.scale - other.scale) < core_geometry_1.Geometry.smallFraction);
|
|
61
61
|
}
|
|
62
|
+
/** Convert Helmert2DWithZOffset object into Transfrom object
|
|
63
|
+
* @public */
|
|
64
|
+
convertHelmertToTransform() {
|
|
65
|
+
const rotationXY = core_geometry_1.Matrix3d.createRotationAroundAxisIndex(core_geometry_1.AxisIndex.Z, core_geometry_1.Angle.createDegrees(this?.rotDeg));
|
|
66
|
+
rotationXY.scaleColumnsInPlace(this.scale, this.scale, 1.0);
|
|
67
|
+
const translation = core_geometry_1.Vector3d.create(this.translationX, this.translationY, this.translationZ);
|
|
68
|
+
const helmertTransform = core_geometry_1.Transform.createRefs(translation, rotationXY);
|
|
69
|
+
return helmertTransform;
|
|
70
|
+
}
|
|
62
71
|
}
|
|
63
72
|
exports.Helmert2DWithZOffset = Helmert2DWithZOffset;
|
|
64
73
|
/** Additional Transform implementation.
|