@itwin/core-backend 5.3.0-dev.2 → 5.3.0-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/IModelDb.js +1 -1
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/annotations/FrameGeometry.js +6 -6
- package/lib/cjs/annotations/FrameGeometry.js.map +1 -1
- package/lib/cjs/annotations/LeaderGeometry.js +4 -4
- package/lib/cjs/annotations/LeaderGeometry.js.map +1 -1
- package/lib/cjs/annotations/TextBlockGeometry.js +3 -3
- package/lib/cjs/annotations/TextBlockGeometry.js.map +1 -1
- package/lib/cjs/annotations/TextBlockLayout.d.ts +2 -2
- package/lib/cjs/annotations/TextBlockLayout.d.ts.map +1 -1
- package/lib/cjs/annotations/TextBlockLayout.js +52 -25
- package/lib/cjs/annotations/TextBlockLayout.js.map +1 -1
- package/lib/esm/IModelDb.js +1 -1
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/annotations/FrameGeometry.js +6 -6
- package/lib/esm/annotations/FrameGeometry.js.map +1 -1
- package/lib/esm/annotations/LeaderGeometry.js +4 -4
- package/lib/esm/annotations/LeaderGeometry.js.map +1 -1
- package/lib/esm/annotations/TextBlockGeometry.js +3 -3
- package/lib/esm/annotations/TextBlockGeometry.js.map +1 -1
- package/lib/esm/annotations/TextBlockLayout.d.ts +2 -2
- package/lib/esm/annotations/TextBlockLayout.d.ts.map +1 -1
- package/lib/esm/annotations/TextBlockLayout.js +52 -25
- package/lib/esm/annotations/TextBlockLayout.js.map +1 -1
- package/lib/esm/test/AnnotationTestUtils.js +1 -1
- package/lib/esm/test/AnnotationTestUtils.js.map +1 -1
- package/lib/esm/test/annotations/Fields.test.js +2 -2
- package/lib/esm/test/annotations/Fields.test.js.map +1 -1
- package/lib/esm/test/annotations/FrameGeometry.test.js +4 -4
- package/lib/esm/test/annotations/FrameGeometry.test.js.map +1 -1
- package/lib/esm/test/annotations/LeaderGeometry.test.js +8 -8
- package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
- package/lib/esm/test/annotations/TextAnnotation.test.js +20 -22
- package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
- package/lib/esm/test/annotations/TextBlock.test.js +218 -151
- package/lib/esm/test/annotations/TextBlock.test.js.map +1 -1
- package/package.json +12 -12
|
@@ -21,20 +21,20 @@ export function appendFrameToBuilder(builder, frame, range, transform, geomParam
|
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
23
23
|
const params = geomParams.clone();
|
|
24
|
-
if (frame.
|
|
24
|
+
if (frame.fillColor === "none" || frame.fillColor === undefined) {
|
|
25
25
|
params.fillDisplay = FillDisplay.Never;
|
|
26
26
|
}
|
|
27
|
-
else if (frame.
|
|
27
|
+
else if (frame.fillColor === "background") {
|
|
28
28
|
params.backgroundFill = BackgroundFill.Solid;
|
|
29
29
|
params.fillDisplay = FillDisplay.Blanking;
|
|
30
30
|
}
|
|
31
|
-
else if (frame.
|
|
32
|
-
params.fillColor = ColorDef.fromJSON(frame.
|
|
31
|
+
else if (frame.fillColor !== "subcategory") {
|
|
32
|
+
params.fillColor = ColorDef.fromJSON(frame.fillColor);
|
|
33
33
|
params.lineColor = params.fillColor;
|
|
34
34
|
params.fillDisplay = FillDisplay.Blanking;
|
|
35
35
|
}
|
|
36
|
-
if (frame.
|
|
37
|
-
params.lineColor = ColorDef.fromJSON(frame.
|
|
36
|
+
if (frame.borderColor !== "subcategory") {
|
|
37
|
+
params.lineColor = ColorDef.fromJSON(frame.borderColor);
|
|
38
38
|
params.weight = frame.borderWeight;
|
|
39
39
|
}
|
|
40
40
|
const frameGeometry = computeFrame({ frame: frame.shape, range, transform });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FrameGeometry.js","sourceRoot":"","sources":["../../../src/annotations/FrameGeometry.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,cAAc,EAAE,Q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,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IAEtD,6CAA6C;IAC7C,MAAM,cAAc,GAAG,GAAG,GAAG,CAAC,CAAC;IAC/B,MAAM,QAAQ,GAAc,EAAE,CAAC;IAE/B,8BAA8B;IAC9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,GAAG,cAAc,GAAG,WAAW,CAAC,CAAC;QACpE,MAAM,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;QACzD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1E,CAAC;IAED,oBAAoB;IACpB,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3B,4BAA4B;IAC5B,MAAM,KAAK,GAAG,YAAY,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAClD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;AACxD,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 ElementGeometry\n */\n\n\nimport { BackgroundFill, ColorDef, ElementGeometry, FillDisplay, GeometryParams, TextAnnotationFrameShape, TextFrameStyleProps } from \"@itwin/core-common\";\nimport { Angle, AngleSweep, Arc3d, LineString3d, Loop, Path, Point3d, Range2d, Transform, Vector2d } from \"@itwin/core-geometry\";\n\n/**\n * Based on the frame style, this method will construct and append [[GeometryParams]] (for line style) and a [[Loop]] (for the frame shape) to the builder.\n * @param builder that will be appended to in place\n * @param frame\n * @param range to enclose with the frame\n * @param transform that transforms the range to world coordinates\n * @returns `true` if any geometry was appended to the builder\n* @beta\n */\nexport function appendFrameToBuilder(builder: ElementGeometry.Builder, frame: TextFrameStyleProps, range: Range2d, transform: Transform, geomParams: GeometryParams): boolean {\n if (frame.shape === \"none\" || frame.shape === undefined) {\n return false;\n }\n\n const params = geomParams.clone();\n\n if (frame.fill === \"none\" || frame.fill === undefined) {\n params.fillDisplay = FillDisplay.Never;\n } else if (frame.fill === \"background\") {\n params.backgroundFill = BackgroundFill.Solid;\n params.fillDisplay = FillDisplay.Blanking;\n } else if (frame.fill !== \"subcategory\") {\n params.fillColor = ColorDef.fromJSON(frame.fill);\n params.lineColor = params.fillColor;\n params.fillDisplay = FillDisplay.Blanking;\n }\n\n if (frame.border !== \"subcategory\") {\n params.lineColor = ColorDef.fromJSON(frame.border);\n params.weight = frame.borderWeight;\n }\n\n const frameGeometry = computeFrame({ frame: frame.shape, range, transform });\n if (!builder.appendGeometryParamsChange(params) || !builder.appendGeometryQuery(frameGeometry)) {\n return false;\n }\n\n // The tile generator does not produce an outline for shapes with blanking fill. We must add the outline separately.\n if (params.fillDisplay === FillDisplay.Blanking) {\n const outlineParams = params.clone();\n outlineParams.fillDisplay = FillDisplay.Never;\n if (!builder.appendGeometryParamsChange(outlineParams) || !builder.appendGeometryQuery(frameGeometry)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Arguments for the [[computeFrame]] method.\n * @beta\n */\nexport interface ComputeFrameArgs {\n /** Frame shape to be calculated */\n frame: Exclude<TextAnnotationFrameShape, \"none\">;\n /** Range to be enclosed */\n range: Range2d;\n /** Transform that translates and rotates the range to world coordinates */\n transform: Transform;\n}\n\n/**\n * Computes the frame geometry based on the provided frame shape and range.\n * @returns a [Loop]($geometry) or [Path]($geometry) (if it's just a line) that represents the frame geometry\n * @beta\n */\nexport function computeFrame(args: ComputeFrameArgs): Loop | Path {\n switch (args.frame) {\n case \"line\": return computeLine(args.range, args.transform);\n case \"rectangle\": return computeRectangle(args.range, args.transform);\n case \"circle\": return computeCircle(args.range, args.transform);\n case \"equilateralTriangle\": return computeTriangle(args.range, args.transform);\n case \"diamond\": return computeDiamond(args.range, args.transform);\n case \"square\": return computeSquare(args.range, args.transform);\n case \"pentagon\": return computePolygon(5, args.range, args.transform, 90);\n case \"hexagon\": return computePolygon(6, args.range, args.transform);\n case \"octagon\": return computePolygon(8, args.range, args.transform, 180 / 8); // or pi/8 in radians\n case \"capsule\": return computeCapsule(args.range, args.transform);\n case \"roundedRectangle\": return computeRoundedRectangle(args.range, args.transform);\n default: return computeRectangle(args.range, args.transform);\n }\n}\n\n/**\n * Arguments for the [[computeIntervalPoints]] method.\n * @beta\n */\nexport interface ComputeIntervalPointsArgs extends ComputeFrameArgs {\n /** A factor applied to divide each straight edge. A value of 1 will place a single point on each vertex. */\n lineIntervalFactor?: number;\n /** A factor applied to divide each straight edge. A value of 1 will place a single point on each vertex. */\n arcIntervalFactor?: number;\n}\n\n/**\n * Computes points along the edges of the frame geometry based on the provided frame shape, range, and interval factors.\n * These can be used for snapping or attaching leaders.\n * @returns an array of [[Point3d]] that represent the points along the edges of the frame geometry. Returns `undefined` if the loop created by `computeFrame` is empty.\n * @beta\n */\nexport function computeIntervalPoints({ frame, range, transform, lineIntervalFactor = 0.5, arcIntervalFactor = 0.25 }: ComputeIntervalPointsArgs): Point3d[] | undefined {\n const points: Point3d[] = [];\n const curves = computeFrame({ frame, range, transform }).collectCurvePrimitives(undefined, false, true);\n\n curves.forEach((curve) => {\n const end = curve instanceof Arc3d ? arcIntervalFactor : lineIntervalFactor;\n for (let interval = 0; interval <= 1; interval += end) {\n points.push(curve.fractionToPoint(interval));\n }\n });\n return points;\n}\n\n/** Line - currently just adds an underline. Once we have leaders, this method may change. */\nconst computeLine = (range: Range2d, transform: Transform): Path => {\n const points = [Point3d.create(range.low.x, range.low.y), Point3d.create(range.high.x, range.low.y)];\n const frame = LineString3d.createPoints(points);\n\n return Path.create(frame.cloneTransformed(transform));\n}\n\n/** Rectangle - simplest frame */\nconst computeRectangle = (range: Range2d, transform: Transform): Loop => {\n const points = range.corners3d(true);\n const frame = LineString3d.createPoints(points);\n\n return Loop.create(frame.cloneTransformed(transform));\n}\n\n/** Rounded Rectangle: each corner will be turned into an arc with the radius of the arc being the @param radiusFactor * the height (yLength) of the range */\nconst computeRoundedRectangle = (range: Range2d, transform: Transform, radiusFactor: number = 0.25): Loop => {\n const radius = range.yLength() * radiusFactor * Math.sqrt(2);\n // We're going to circumscribe the range with our rounded edges. The corners of the range will fall on 45 degree angles.\n const radiusOffsetFactor = range.yLength() * radiusFactor;\n\n // These values are the origins of the circles\n const inLeft = range.low.x + radiusOffsetFactor;\n const inRight = range.high.x - radiusOffsetFactor;\n const inBottom = range.low.y + radiusOffsetFactor;\n const inTop = range.high.y - radiusOffsetFactor\n\n // These values exist on the circles\n const exLeft = inLeft - radius;\n const exRight = inRight + radius;\n const exBottom = inBottom - radius;\n const exTop = inTop + radius;\n\n const q1 = AngleSweep.createStartEndDegrees(0, 90);\n const q2 = AngleSweep.createStartEndDegrees(90, 180);\n const q3 = AngleSweep.createStartEndDegrees(180, 270);\n const q4 = AngleSweep.createStartEndDegrees(270, 360);\n\n\n const curves = [\n LineString3d.create([Point3d.create(inRight, exTop), Point3d.create(inLeft, exTop)]), // top\n Arc3d.createXY(Point3d.create(inLeft, inTop), radius, q2), // top left\n LineString3d.create([Point3d.create(exLeft, inTop), Point3d.create(exLeft, inBottom)]), // left\n Arc3d.createXY(Point3d.create(inLeft, inBottom), radius, q3), // bottom left\n LineString3d.create([Point3d.create(inLeft, exBottom), Point3d.create(inRight, exBottom)]), // bottom\n Arc3d.createXY(Point3d.create(inRight, inBottom), radius, q4), // bottom right\n LineString3d.create([Point3d.create(exRight, inBottom), Point3d.create(exRight, inTop)]), // right\n Arc3d.createXY(Point3d.create(inRight, inTop), radius, q1), // top right\n ];\n\n return Loop.createArray(curves.map((curve) => curve.cloneTransformed(transform)))\n}\n\n\n/** Circle */\nconst computeCircle = (range: Range2d, transform: Transform): Loop => {\n const radius = range.low.distance(range.high) / 2;\n const frame = Arc3d.createXY(Point3d.createFrom(range.center), radius);\n return Loop.create(frame.cloneTransformed(transform));\n}\n\n/** Equilateral Triangle */\nconst computeTriangle = (range: Range2d, transform: Transform): Loop => {\n\n const xLength = range.xLength();\n const yLength = range.yLength();\n const center = range.center;\n const points: Point3d[] = [];\n\n const magnitude = (xLength > yLength) ? (xLength * Math.sqrt(3) + yLength) / 2 : (yLength * Math.sqrt(3) + xLength) / 2;\n\n const v1 = Vector2d.create(0, magnitude);\n const vectors = [\n v1, // top\n v1.rotateXY(Angle.createDegrees(120)), // left\n v1.rotateXY(Angle.createDegrees(240)), // right\n v1 // top\n ];\n\n vectors.forEach((v) => {\n points.push(Point3d.create(center.x + v.x, center.y + v.y));\n });\n\n const frame = LineString3d.createPoints(points);\n\n return Loop.create(frame.cloneTransformed(transform));\n}\n\n/** Diamond (square rotated 45 degrees) */\nconst computeDiamond = (range: Range2d, transform: Transform): Loop => {\n const offset = (range.xLength() + range.yLength()) / 2;\n const center = range.center;\n\n const points = [\n Point3d.createFrom({ x: center.x, y: center.y + offset }), // top\n Point3d.createFrom({ x: center.x + offset, y: center.y }), // right\n Point3d.createFrom({ x: center.x, y: center.y - offset }), // bottom\n Point3d.createFrom({ x: center.x - offset, y: center.y }), // left\n Point3d.createFrom({ x: center.x, y: center.y + offset }), // top\n ];\n\n const frame = LineString3d.createPoints(points);\n\n return Loop.create(frame.cloneTransformed(transform));\n}\n\n/** Square */\nconst computeSquare = (range: Range2d, transform: Transform): Loop => {\n\n // Extend range\n const xLength = range.xLength() / 2;\n const yLength = range.yLength() / 2;\n const center = range.center;\n if (xLength > yLength) {\n range.extendPoint({ x: center.x, y: center.y + xLength });\n range.extendPoint({ x: center.x, y: center.y - xLength });\n } else {\n range.extendPoint({ x: center.x + yLength, y: center.y });\n range.extendPoint({ x: center.x - yLength, y: center.y });\n }\n\n const points = range.corners3d(true);\n const frame = LineString3d.createPoints(points);\n\n return Loop.create(frame.cloneTransformed(transform));\n}\n\n/** Capsule (or pill shape) */\nconst computeCapsule = (range: Range2d, transform: Transform): Loop => {\n const height = range.yLength();\n const radius = height * (Math.sqrt(2) / 2);\n\n // We're going to circumscribe the range with our rounded edges. The corners of the range will fall on 45 degree angles.\n const radiusOffsetFactor = height / 2;\n\n // These values are the origins of the circles\n const inLeft = range.low.x + radiusOffsetFactor;\n const inRight = range.high.x - radiusOffsetFactor;\n const inBottom = range.low.y + radiusOffsetFactor;\n const inTop = range.high.y - radiusOffsetFactor\n\n // These values exist on the circles\n const exBottom = inBottom - radius;\n const exTop = inTop + radius;\n\n const leftHalfCircle = AngleSweep.createStartEndDegrees(90, 270);\n const rightHalfCircle = AngleSweep.createStartEndDegrees(-90, 90);\n\n const curves = [\n LineString3d.create([Point3d.create(inRight, exTop), Point3d.create(inLeft, exTop)]), // top\n Arc3d.createXY(Point3d.create(inLeft, range.center.y), radius, leftHalfCircle), // left\n LineString3d.create([Point3d.create(inLeft, exBottom), Point3d.create(inRight, exBottom)]), // bottom\n Arc3d.createXY(Point3d.create(inRight, range.center.y), radius, rightHalfCircle), // right\n ];\n\n return Loop.createArray(curves.map((curve) => curve.cloneTransformed(transform)));\n}\n\n/** Regular polygon with n sides: note, this a generic method that can be used to create any polygon, but the frame will not be as tightly encapsulating. */\nconst computePolygon = (n: number, range: Range2d, transform: Transform, angleOffset: number = 0): Loop => {\n // These are math terms: cspell:ignore inradius circumradius\n if (n < 3) throw new Error(\"A polygon must have at least 3 sides.\");\n\n // We're assuming the polygon is a regular polygon with `n` sides.\n // The center of the polygon is the center of the range.\n const center = range.center;\n // The inradius is the distance from the center to the midpoint of each side of the polygon. On our range, this coincides with the distance from the center to one of its corners.\n const inradius = range.low.distance(range.high) / 2;\n // The circumradius is the distance from the center to each vertex of the polygon.\n const circumradius = inradius / Math.cos(Math.PI / n);\n\n // The exterior angles add up to 360 degrees.\n const angleIncrement = 360 / n;\n const vertices: Point3d[] = [];\n\n // Add a point for each vertex\n for (let i = 0; i < n; i++) {\n const angle = Angle.createDegrees(i * angleIncrement + angleOffset);\n const vector = Vector2d.createPolar(circumradius, angle);\n vertices.push(Point3d.create(center.x + vector.x, center.y + vector.y));\n }\n\n // Close the polygon\n vertices.push(vertices[0]);\n\n // Finally compute the loop!\n const frame = LineString3d.createPoints(vertices);\n return Loop.create(frame.cloneTransformed(transform));\n};"]}
|
|
1
|
+
{"version":3,"file":"FrameGeometry.js","sourceRoot":"","sources":["../../../src/annotations/FrameGeometry.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAmB,WAAW,EAAiE,MAAM,oBAAoB,CAAC;AAC3J,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAsB,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEjI;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAgC,EAAE,KAA0B,EAAE,KAAc,EAAE,SAAoB,EAAE,UAA0B;IACjK,IAAI,KAAK,CAAC,KAAK,KAAK,MAAM,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACxD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC;IAElC,IAAI,KAAK,CAAC,SAAS,KAAK,MAAM,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAChE,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC;IACzC,CAAC;SAAM,IAAI,KAAK,CAAC,SAAS,KAAK,YAAY,EAAE,CAAC;QAC5C,MAAM,CAAC,cAA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A4B;IAC5B,MAAM,KAAK,GAAG,YAAY,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAClD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;AACxD,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 ElementGeometry\n */\n\n\nimport { BackgroundFill, ColorDef, ElementGeometry, FillDisplay, GeometryParams, TextAnnotationFrameShape, TextFrameStyleProps } from \"@itwin/core-common\";\nimport { Angle, AngleSweep, Arc3d, LineString3d, Loop, Path, Point3d, Range2d, Transform, Vector2d } from \"@itwin/core-geometry\";\n\n/**\n * Based on the frame style, this method will construct and append [[GeometryParams]] (for line style) and a [[Loop]] (for the frame shape) to the builder.\n * @param builder that will be appended to in place\n * @param frame\n * @param range to enclose with the frame\n * @param transform that transforms the range to world coordinates\n * @returns `true` if any geometry was appended to the builder\n* @beta\n */\nexport function appendFrameToBuilder(builder: ElementGeometry.Builder, frame: TextFrameStyleProps, range: Range2d, transform: Transform, geomParams: GeometryParams): boolean {\n if (frame.shape === \"none\" || frame.shape === undefined) {\n return false;\n }\n\n const params = geomParams.clone();\n\n if (frame.fillColor === \"none\" || frame.fillColor === undefined) {\n params.fillDisplay = FillDisplay.Never;\n } else if (frame.fillColor === \"background\") {\n params.backgroundFill = BackgroundFill.Solid;\n params.fillDisplay = FillDisplay.Blanking;\n } else if (frame.fillColor !== \"subcategory\") {\n params.fillColor = ColorDef.fromJSON(frame.fillColor);\n params.lineColor = params.fillColor;\n params.fillDisplay = FillDisplay.Blanking;\n }\n\n if (frame.borderColor !== \"subcategory\") {\n params.lineColor = ColorDef.fromJSON(frame.borderColor);\n params.weight = frame.borderWeight;\n }\n\n const frameGeometry = computeFrame({ frame: frame.shape, range, transform });\n if (!builder.appendGeometryParamsChange(params) || !builder.appendGeometryQuery(frameGeometry)) {\n return false;\n }\n\n // The tile generator does not produce an outline for shapes with blanking fill. We must add the outline separately.\n if (params.fillDisplay === FillDisplay.Blanking) {\n const outlineParams = params.clone();\n outlineParams.fillDisplay = FillDisplay.Never;\n if (!builder.appendGeometryParamsChange(outlineParams) || !builder.appendGeometryQuery(frameGeometry)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Arguments for the [[computeFrame]] method.\n * @beta\n */\nexport interface ComputeFrameArgs {\n /** Frame shape to be calculated */\n frame: Exclude<TextAnnotationFrameShape, \"none\">;\n /** Range to be enclosed */\n range: Range2d;\n /** Transform that translates and rotates the range to world coordinates */\n transform: Transform;\n}\n\n/**\n * Computes the frame geometry based on the provided frame shape and range.\n * @returns a [Loop]($geometry) or [Path]($geometry) (if it's just a line) that represents the frame geometry\n * @beta\n */\nexport function computeFrame(args: ComputeFrameArgs): Loop | Path {\n switch (args.frame) {\n case \"line\": return computeLine(args.range, args.transform);\n case \"rectangle\": return computeRectangle(args.range, args.transform);\n case \"circle\": return computeCircle(args.range, args.transform);\n case \"equilateralTriangle\": return computeTriangle(args.range, args.transform);\n case \"diamond\": return computeDiamond(args.range, args.transform);\n case \"square\": return computeSquare(args.range, args.transform);\n case \"pentagon\": return computePolygon(5, args.range, args.transform, 90);\n case \"hexagon\": return computePolygon(6, args.range, args.transform);\n case \"octagon\": return computePolygon(8, args.range, args.transform, 180 / 8); // or pi/8 in radians\n case \"capsule\": return computeCapsule(args.range, args.transform);\n case \"roundedRectangle\": return computeRoundedRectangle(args.range, args.transform);\n default: return computeRectangle(args.range, args.transform);\n }\n}\n\n/**\n * Arguments for the [[computeIntervalPoints]] method.\n * @beta\n */\nexport interface ComputeIntervalPointsArgs extends ComputeFrameArgs {\n /** A factor applied to divide each straight edge. A value of 1 will place a single point on each vertex. */\n lineIntervalFactor?: number;\n /** A factor applied to divide each straight edge. A value of 1 will place a single point on each vertex. */\n arcIntervalFactor?: number;\n}\n\n/**\n * Computes points along the edges of the frame geometry based on the provided frame shape, range, and interval factors.\n * These can be used for snapping or attaching leaders.\n * @returns an array of [[Point3d]] that represent the points along the edges of the frame geometry. Returns `undefined` if the loop created by `computeFrame` is empty.\n * @beta\n */\nexport function computeIntervalPoints({ frame, range, transform, lineIntervalFactor = 0.5, arcIntervalFactor = 0.25 }: ComputeIntervalPointsArgs): Point3d[] | undefined {\n const points: Point3d[] = [];\n const curves = computeFrame({ frame, range, transform }).collectCurvePrimitives(undefined, false, true);\n\n curves.forEach((curve) => {\n const end = curve instanceof Arc3d ? arcIntervalFactor : lineIntervalFactor;\n for (let interval = 0; interval <= 1; interval += end) {\n points.push(curve.fractionToPoint(interval));\n }\n });\n return points;\n}\n\n/** Line - currently just adds an underline. Once we have leaders, this method may change. */\nconst computeLine = (range: Range2d, transform: Transform): Path => {\n const points = [Point3d.create(range.low.x, range.low.y), Point3d.create(range.high.x, range.low.y)];\n const frame = LineString3d.createPoints(points);\n\n return Path.create(frame.cloneTransformed(transform));\n}\n\n/** Rectangle - simplest frame */\nconst computeRectangle = (range: Range2d, transform: Transform): Loop => {\n const points = range.corners3d(true);\n const frame = LineString3d.createPoints(points);\n\n return Loop.create(frame.cloneTransformed(transform));\n}\n\n/** Rounded Rectangle: each corner will be turned into an arc with the radius of the arc being the @param radiusFactor * the height (yLength) of the range */\nconst computeRoundedRectangle = (range: Range2d, transform: Transform, radiusFactor: number = 0.25): Loop => {\n const radius = range.yLength() * radiusFactor * Math.sqrt(2);\n // We're going to circumscribe the range with our rounded edges. The corners of the range will fall on 45 degree angles.\n const radiusOffsetFactor = range.yLength() * radiusFactor;\n\n // These values are the origins of the circles\n const inLeft = range.low.x + radiusOffsetFactor;\n const inRight = range.high.x - radiusOffsetFactor;\n const inBottom = range.low.y + radiusOffsetFactor;\n const inTop = range.high.y - radiusOffsetFactor\n\n // These values exist on the circles\n const exLeft = inLeft - radius;\n const exRight = inRight + radius;\n const exBottom = inBottom - radius;\n const exTop = inTop + radius;\n\n const q1 = AngleSweep.createStartEndDegrees(0, 90);\n const q2 = AngleSweep.createStartEndDegrees(90, 180);\n const q3 = AngleSweep.createStartEndDegrees(180, 270);\n const q4 = AngleSweep.createStartEndDegrees(270, 360);\n\n\n const curves = [\n LineString3d.create([Point3d.create(inRight, exTop), Point3d.create(inLeft, exTop)]), // top\n Arc3d.createXY(Point3d.create(inLeft, inTop), radius, q2), // top left\n LineString3d.create([Point3d.create(exLeft, inTop), Point3d.create(exLeft, inBottom)]), // left\n Arc3d.createXY(Point3d.create(inLeft, inBottom), radius, q3), // bottom left\n LineString3d.create([Point3d.create(inLeft, exBottom), Point3d.create(inRight, exBottom)]), // bottom\n Arc3d.createXY(Point3d.create(inRight, inBottom), radius, q4), // bottom right\n LineString3d.create([Point3d.create(exRight, inBottom), Point3d.create(exRight, inTop)]), // right\n Arc3d.createXY(Point3d.create(inRight, inTop), radius, q1), // top right\n ];\n\n return Loop.createArray(curves.map((curve) => curve.cloneTransformed(transform)))\n}\n\n\n/** Circle */\nconst computeCircle = (range: Range2d, transform: Transform): Loop => {\n const radius = range.low.distance(range.high) / 2;\n const frame = Arc3d.createXY(Point3d.createFrom(range.center), radius);\n return Loop.create(frame.cloneTransformed(transform));\n}\n\n/** Equilateral Triangle */\nconst computeTriangle = (range: Range2d, transform: Transform): Loop => {\n\n const xLength = range.xLength();\n const yLength = range.yLength();\n const center = range.center;\n const points: Point3d[] = [];\n\n const magnitude = (xLength > yLength) ? (xLength * Math.sqrt(3) + yLength) / 2 : (yLength * Math.sqrt(3) + xLength) / 2;\n\n const v1 = Vector2d.create(0, magnitude);\n const vectors = [\n v1, // top\n v1.rotateXY(Angle.createDegrees(120)), // left\n v1.rotateXY(Angle.createDegrees(240)), // right\n v1 // top\n ];\n\n vectors.forEach((v) => {\n points.push(Point3d.create(center.x + v.x, center.y + v.y));\n });\n\n const frame = LineString3d.createPoints(points);\n\n return Loop.create(frame.cloneTransformed(transform));\n}\n\n/** Diamond (square rotated 45 degrees) */\nconst computeDiamond = (range: Range2d, transform: Transform): Loop => {\n const offset = (range.xLength() + range.yLength()) / 2;\n const center = range.center;\n\n const points = [\n Point3d.createFrom({ x: center.x, y: center.y + offset }), // top\n Point3d.createFrom({ x: center.x + offset, y: center.y }), // right\n Point3d.createFrom({ x: center.x, y: center.y - offset }), // bottom\n Point3d.createFrom({ x: center.x - offset, y: center.y }), // left\n Point3d.createFrom({ x: center.x, y: center.y + offset }), // top\n ];\n\n const frame = LineString3d.createPoints(points);\n\n return Loop.create(frame.cloneTransformed(transform));\n}\n\n/** Square */\nconst computeSquare = (range: Range2d, transform: Transform): Loop => {\n\n // Extend range\n const xLength = range.xLength() / 2;\n const yLength = range.yLength() / 2;\n const center = range.center;\n if (xLength > yLength) {\n range.extendPoint({ x: center.x, y: center.y + xLength });\n range.extendPoint({ x: center.x, y: center.y - xLength });\n } else {\n range.extendPoint({ x: center.x + yLength, y: center.y });\n range.extendPoint({ x: center.x - yLength, y: center.y });\n }\n\n const points = range.corners3d(true);\n const frame = LineString3d.createPoints(points);\n\n return Loop.create(frame.cloneTransformed(transform));\n}\n\n/** Capsule (or pill shape) */\nconst computeCapsule = (range: Range2d, transform: Transform): Loop => {\n const height = range.yLength();\n const radius = height * (Math.sqrt(2) / 2);\n\n // We're going to circumscribe the range with our rounded edges. The corners of the range will fall on 45 degree angles.\n const radiusOffsetFactor = height / 2;\n\n // These values are the origins of the circles\n const inLeft = range.low.x + radiusOffsetFactor;\n const inRight = range.high.x - radiusOffsetFactor;\n const inBottom = range.low.y + radiusOffsetFactor;\n const inTop = range.high.y - radiusOffsetFactor\n\n // These values exist on the circles\n const exBottom = inBottom - radius;\n const exTop = inTop + radius;\n\n const leftHalfCircle = AngleSweep.createStartEndDegrees(90, 270);\n const rightHalfCircle = AngleSweep.createStartEndDegrees(-90, 90);\n\n const curves = [\n LineString3d.create([Point3d.create(inRight, exTop), Point3d.create(inLeft, exTop)]), // top\n Arc3d.createXY(Point3d.create(inLeft, range.center.y), radius, leftHalfCircle), // left\n LineString3d.create([Point3d.create(inLeft, exBottom), Point3d.create(inRight, exBottom)]), // bottom\n Arc3d.createXY(Point3d.create(inRight, range.center.y), radius, rightHalfCircle), // right\n ];\n\n return Loop.createArray(curves.map((curve) => curve.cloneTransformed(transform)));\n}\n\n/** Regular polygon with n sides: note, this a generic method that can be used to create any polygon, but the frame will not be as tightly encapsulating. */\nconst computePolygon = (n: number, range: Range2d, transform: Transform, angleOffset: number = 0): Loop => {\n // These are math terms: cspell:ignore inradius circumradius\n if (n < 3) throw new Error(\"A polygon must have at least 3 sides.\");\n\n // We're assuming the polygon is a regular polygon with `n` sides.\n // The center of the polygon is the center of the range.\n const center = range.center;\n // The inradius is the distance from the center to the midpoint of each side of the polygon. On our range, this coincides with the distance from the center to one of its corners.\n const inradius = range.low.distance(range.high) / 2;\n // The circumradius is the distance from the center to each vertex of the polygon.\n const circumradius = inradius / Math.cos(Math.PI / n);\n\n // The exterior angles add up to 360 degrees.\n const angleIncrement = 360 / n;\n const vertices: Point3d[] = [];\n\n // Add a point for each vertex\n for (let i = 0; i < n; i++) {\n const angle = Angle.createDegrees(i * angleIncrement + angleOffset);\n const vector = Vector2d.createPolar(circumradius, angle);\n vertices.push(Point3d.create(center.x + vector.x, center.y + vector.y));\n }\n\n // Close the polygon\n vertices.push(vertices[0]);\n\n // Finally compute the loop!\n const frame = LineString3d.createPoints(vertices);\n return Loop.create(frame.cloneTransformed(transform));\n};"]}
|
|
@@ -28,7 +28,7 @@ import { computeFrame } from "./FrameGeometry";
|
|
|
28
28
|
*/
|
|
29
29
|
export function appendLeadersToBuilder(builder, leaders, layout, transform, params, textStyleResolver, scaleFactor) {
|
|
30
30
|
let result = true;
|
|
31
|
-
const
|
|
31
|
+
const scaledBlockTextHeight = textStyleResolver.blockSettings.textHeight * scaleFactor;
|
|
32
32
|
let frame = textStyleResolver.blockSettings.frame;
|
|
33
33
|
// If there is no frame, use a rectangular frame to compute the attachmentPoints for leaders.
|
|
34
34
|
if (frame === undefined || frame.shape === "none") {
|
|
@@ -60,7 +60,7 @@ export function appendLeadersToBuilder(builder, leaders, layout, transform, para
|
|
|
60
60
|
leaderLinePoints.push(point);
|
|
61
61
|
});
|
|
62
62
|
if (leaderStyle.leader.wantElbow) {
|
|
63
|
-
const elbowLength = leaderStyle.leader.elbowLength *
|
|
63
|
+
const elbowLength = leaderStyle.leader.elbowLength * scaledBlockTextHeight;
|
|
64
64
|
const elbowDirection = computeElbowDirection(attachmentPoint, frameCurve, elbowLength);
|
|
65
65
|
if (elbowDirection)
|
|
66
66
|
leaderLinePoints.push(attachmentPoint.plusScaled(elbowDirection, elbowLength));
|
|
@@ -72,8 +72,8 @@ export function appendLeadersToBuilder(builder, leaders, layout, transform, para
|
|
|
72
72
|
const termY = terminatorDirection?.unitCrossProduct(Vector3d.unitZ());
|
|
73
73
|
if (!termY || !terminatorDirection)
|
|
74
74
|
continue; // Assuming leaders without terminators is a valid case.
|
|
75
|
-
const terminatorHeight = leaderStyle.leader.terminatorHeightFactor *
|
|
76
|
-
const terminatorWidth = leaderStyle.leader.terminatorWidthFactor *
|
|
75
|
+
const terminatorHeight = leaderStyle.leader.terminatorHeightFactor * scaledBlockTextHeight;
|
|
76
|
+
const terminatorWidth = leaderStyle.leader.terminatorWidthFactor * scaledBlockTextHeight;
|
|
77
77
|
const basePoint = leader.startPoint.plusScaled(terminatorDirection, terminatorWidth);
|
|
78
78
|
const termPointA = basePoint.plusScaled(termY, terminatorHeight);
|
|
79
79
|
const termPointB = basePoint.plusScaled(termY.negate(), terminatorHeight);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LeaderGeometry.js","sourceRoot":"","sources":["../../../src/annotations/LeaderGeometry.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAA8F,MAAM,oBAAoB,CAAC;AAC1I,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAA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AS,CAAC,CAAC,KAAK,CAAC;QACpD,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC;QAClE,MAAM,MAAM,GAAG,SAAS,CAAC,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;QACvE,IAAI,qBAAqB,GAAG,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAE1G,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YACjD,qBAAqB,GAAG,qBAAqB,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC;YAC7G,cAAc,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC;QAC3C,CAAC;QACD,uFAAuF;QACvF,+EAA+E;QAC/E,MAAM,WAAW,GAAG,qBAAqB,CAAC,UAAU,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC,8CAA8C;QACzH,MAAM,gBAAgB,GAAG,aAAa,CAAC,MAAM,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC;QAClF,MAAM,kBAAkB,GAAG,UAAU,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;QACvG,eAAe,GAAG,kBAAkB,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC;IACzD,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,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 ElementGeometry\n */\n\nimport { ColorDef, ElementGeometry, GeometryParams, TextAnnotationLeader, TextFrameStyleProps, TextStyleColor } from \"@itwin/core-common\";\nimport { CurveCurve, LineSegment3d, LineString3d, Loop, Path, Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\nimport { computeFrame } from \"./FrameGeometry\";\nimport { TextBlockLayout, TextStyleResolver } from \"./TextBlockLayout\";\n\n/**\n * Constructs and appends leader lines and their terminators to the provided geometry builder for a text annotation.\n *\n * This function processes an array of `TextAnnotationLeader` objects, computes their attachment points\n * relative to a text frame (or a default rectangular frame if none is provided), and appends the leader\n * line and terminator geometry to the builder. It also applies color overrides if specified\n * in the leader's style overrides.\n *\n * @param builder - The geometry builder to which the leader geometries will be appended.\n * @param leaders - An array of leader properties.\n * @param layout - The layout information for the text block, including its range.\n * @param transform - The transform to apply to the frame and leader geometry.\n * @param params - The geometry parameters, such as color, to use for the leader lines.\n * @param textStyleResolver - Resolver for text styles, used to obtain leader styles.\n * @param scaleFactor - The scale factor to apply to leader dimensions, usually comes from the `scaleFactor` of a [[Drawing]] element.\n * @returns `true` if at least one leader with a terminator was successfully appended; otherwise, `false`.\n * @beta\n */\nexport function appendLeadersToBuilder(builder: ElementGeometry.Builder, leaders: TextAnnotationLeader[], layout: TextBlockLayout, transform: Transform, params: GeometryParams, textStyleResolver: TextStyleResolver, scaleFactor: number): boolean {\n let result = true;\n const scaledLineHeight = textStyleResolver.blockSettings.lineHeight * scaleFactor;\n let frame: TextFrameStyleProps | undefined = textStyleResolver.blockSettings.frame;\n\n // If there is no frame, use a rectangular frame to compute the attachmentPoints for leaders.\n if (frame === undefined || frame.shape === \"none\") {\n frame = { shape: \"rectangle\" }\n }\n if (frame.shape === undefined || frame.shape === \"none\") return false;\n const frameCurve = computeFrame({ frame: frame.shape, range: layout.range, transform });\n\n for (const leader of leaders) {\n const leaderStyle = textStyleResolver.resolveSettings(leader.styleOverrides ?? {}, true);\n\n let effectiveColor: TextStyleColor = \"subcategory\";\n\n if (leaderStyle.leader.color === \"inherit\") {\n effectiveColor = leaderStyle.color;\n } else if (leaderStyle.leader.color !== \"subcategory\") {\n effectiveColor = leaderStyle.leader.color;\n }\n\n if (effectiveColor !== \"subcategory\") {\n params.lineColor = ColorDef.fromJSON(effectiveColor);\n result = result && builder.appendGeometryParamsChange(params);\n }\n\n const attachmentPoint = computeLeaderAttachmentPoint(leader, frameCurve, layout, transform);\n if (!attachmentPoint) return false;\n\n // Leader line geometry\n const leaderLinePoints: Point3d[] = [];\n\n leaderLinePoints.push(leader.startPoint)\n\n leader.intermediatePoints?.forEach((point) => {\n leaderLinePoints.push(point);\n });\n\n if (leaderStyle.leader.wantElbow) {\n const elbowLength = leaderStyle.leader.elbowLength * scaledLineHeight;\n const elbowDirection = computeElbowDirection(attachmentPoint, frameCurve, elbowLength);\n if (elbowDirection)\n leaderLinePoints.push(attachmentPoint.plusScaled(elbowDirection, elbowLength))\n }\n\n leaderLinePoints.push(attachmentPoint)\n\n result = result && builder.appendGeometryQuery(LineString3d.create(leaderLinePoints));\n\n // Terminator geometry\n const terminatorDirection = Vector3d.createStartEnd(\n leaderLinePoints[0], leaderLinePoints[1]\n ).normalize();\n\n const termY = terminatorDirection?.unitCrossProduct(Vector3d.unitZ());\n if (!termY || !terminatorDirection) continue; // Assuming leaders without terminators is a valid case.\n const terminatorHeight = leaderStyle.leader.terminatorHeightFactor * scaledLineHeight;\n const terminatorWidth = leaderStyle.leader.terminatorWidthFactor * scaledLineHeight;\n const basePoint = leader.startPoint.plusScaled(terminatorDirection, terminatorWidth);\n const termPointA = basePoint.plusScaled(termY, terminatorHeight);\n const termPointB = basePoint.plusScaled(termY.negate(), terminatorHeight);\n result = result && builder.appendGeometryQuery(LineString3d.create([termPointA, leader.startPoint, termPointB]));\n\n }\n return result;\n}\n\n\n/**\n * Computes the direction vector for an \"elbow\" for leader based on the attachment point and a frame curve.\n * The elbow direction is determined by whether the attachment point is closer to the left or right side of the frame.\n * If the computed elbow would be tangent to the frame at the intersection, no elbow direction is returned.\n *\n * @param attachmentPoint - The point where the leader attaches.\n * @param frameCurve - The frame curve (either a Loop or Path) to which the leader is attached.\n * @param elbowLength - The length of the elbow segment to be created.\n * @returns The direction vector for the elbow, or `undefined` if the elbow would be tangent to the frame.\n * @beta\n */\nexport function computeElbowDirection(attachmentPoint: Point3d, frameCurve: Loop | Path, elbowLength: number): Vector3d | undefined {\n\n let elbowDirection: Vector3d | undefined;\n // Determine the direction based on the closest point's position relative to the frame\n const isCloserToLeft = Math.abs(attachmentPoint.x - frameCurve.range().low.x) < Math.abs(attachmentPoint.x - frameCurve.range().high.x);\n\n // Decide the direction: left (-X) or right (+X)\n elbowDirection = isCloserToLeft ? Vector3d.unitX().negate() : Vector3d.unitX();\n\n // Verify if the elbow is a tangent to the frame, if yes, do not create an elbow\n const elbowPoint = attachmentPoint.plusScaled(elbowDirection, elbowLength);\n const elbowLine = LineSegment3d.create(attachmentPoint, elbowPoint);\n // Find intersection points between the elbow and the frame\n const intersections = CurveCurve.intersectionXYZPairs(elbowLine, false, frameCurve, false);\n // As the elbow will intersect the frame only at one point, we can safely use the first intersection\n const intersection = intersections[0];\n const curveFraction = intersection.detailB.fraction;\n const derivative = intersection.detailB.curve?.fractionToPointAndDerivative(curveFraction);\n const tangent = derivative?.direction.normalize();\n const lineDirection = Vector3d.createStartEnd(elbowLine.point0Ref, elbowLine.point1Ref).normalize();\n if (tangent && lineDirection) {\n const dot = tangent.dotProduct(lineDirection);\n // If the tangent and line direction are aligned (dot product close to 1 or -1), it's tangent\n if (Math.abs(dot) > 0.999) {\n elbowDirection = undefined;\n }\n }\n return elbowDirection;\n}\n\n/**\n * Computes the attachment point for a leader line on a text annotation frame.\n *\n * The attachment point is determined based on the leader's attachment mode:\n * - `\"Nearest\"`: Finds the closest point on the frame curve to the leader's start point.\n * - `\"KeyPoint\"`: Uses a specific curve segment and fraction along that segment to determine the point.\n * - `\"TextPoint\"`: Calculates a point on the text layout (top/bottom, left/right) and projects it onto the frame curve.\n *\n * @param leader - The leader props.\n * @param frameCurve - The curve (Loop or Path) representing the annotation frame.\n * @param textLayout - The layout information for the text block.\n * @param transform - The transform applied to the text layout.\n * @returns The computed attachment point as a `Point3d`, or `undefined` if it cannot be determined.\n * @beta\n */\nexport function computeLeaderAttachmentPoint(\n leader: TextAnnotationLeader,\n frameCurve: Loop | Path,\n textLayout: TextBlockLayout,\n transform: Transform\n): Point3d | undefined {\n let attachmentPoint: Point3d | undefined;\n\n if (leader.attachment.mode === \"Nearest\") {\n attachmentPoint = frameCurve.closestPoint(leader.startPoint)?.point;\n } else if (leader.attachment.mode === \"KeyPoint\") {\n const curves = frameCurve.collectCurvePrimitives(undefined, false, true);\n const curveIndex = leader.attachment.curveIndex;\n const fraction = leader.attachment.fraction;\n if (curveIndex >= curves.length) {\n // If the curveIndex is invalid, use the last curve\n // This is a fallback to avoid out-of-bounds access\n attachmentPoint = curves[curves.length - 1].fractionToPoint(fraction);\n } else {\n attachmentPoint = curves[curveIndex].fractionToPoint(fraction);\n }\n } else { // attachment.mode=\"TextPoint\"\n let scaleDirection = transform.matrix.getColumn(0).negate(); // direction to draw a scaled line from text attachment point to find intersection point on frame\n let lineIndex: number;\n if (leader.attachment.position.includes(\"Top\")) {\n lineIndex = 0\n } else {\n lineIndex = textLayout.lines.length - 1\n }\n const lineRange = textLayout.lines[lineIndex].range;\n const lineOffset = textLayout.lines[lineIndex].offsetFromDocument;\n const origin = transform.multiplyPoint3d(Point3d.fromJSON(lineOffset));\n let attachmentPointOnText = origin.plusScaled(transform.matrix.getColumn(1), ((lineRange.yLength()) / 2));\n\n if (leader.attachment.position.includes(\"Right\")) {\n attachmentPointOnText = attachmentPointOnText.plusScaled(transform.matrix.getColumn(0), lineRange.xLength());\n scaleDirection = scaleDirection.negate();\n }\n // Find the nearest intersection point on the frame to get the correct attachment point\n // Extend the direction vector to create a target point far along the direction\n const targetPoint = attachmentPointOnText.plusScaled(scaleDirection, 1e6); // Scale the direction vector to a large value\n const intersectionLine = LineSegment3d.create(attachmentPointOnText, targetPoint);\n const closestPointDetail = CurveCurve.intersectionXYZPairs(intersectionLine, false, frameCurve, false);\n attachmentPoint = closestPointDetail[0]?.detailA.point;\n }\n return attachmentPoint;\n}"]}
|
|
1
|
+
{"version":3,"file":"LeaderGeometry.js","sourceRoot":"","sources":["../../../src/annotations/LeaderGeometry.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAA8F,MAAM,oBAAoB,CAAC;AAC1I,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAc,OAAO,EAAa,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACzH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAgC,EAAE,OAA+B,EAAE,MAAuB,EAAE,SAAoB,EAAE,MAAsB,EAAE,iBAAoC,EAAE,WAAmB;IACxO,IAAI,MAAM,GAAG,IAAI,CAAC;IAClB,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,aAAa,CAAC,UAAU,GAAG,WAAW,CAAC;IACvF,IAAI,KAAK,GAAoC,iBAAiB,CAAC,aAAa,CAAC,KAAK,CAAC;IAEnF,6FAA6F;IAC7F,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC;QAClD,KAAK,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,CAAA;IAChC,CAAC;IACD,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IACtE,MAAM,UAAU,GAAG,YAAY,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;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CAAC,MAAM,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC;QAClF,MAAM,kBAAkB,GAAG,UAAU,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;QACvG,eAAe,GAAG,kBAAkB,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC;IACzD,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,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 ElementGeometry\n */\n\nimport { ColorDef, ElementGeometry, GeometryParams, TextAnnotationLeader, TextFrameStyleProps, TextStyleColor } from \"@itwin/core-common\";\nimport { CurveCurve, LineSegment3d, LineString3d, Loop, Path, Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\nimport { computeFrame } from \"./FrameGeometry\";\nimport { TextBlockLayout, TextStyleResolver } from \"./TextBlockLayout\";\n\n/**\n * Constructs and appends leader lines and their terminators to the provided geometry builder for a text annotation.\n *\n * This function processes an array of `TextAnnotationLeader` objects, computes their attachment points\n * relative to a text frame (or a default rectangular frame if none is provided), and appends the leader\n * line and terminator geometry to the builder. It also applies color overrides if specified\n * in the leader's style overrides.\n *\n * @param builder - The geometry builder to which the leader geometries will be appended.\n * @param leaders - An array of leader properties.\n * @param layout - The layout information for the text block, including its range.\n * @param transform - The transform to apply to the frame and leader geometry.\n * @param params - The geometry parameters, such as color, to use for the leader lines.\n * @param textStyleResolver - Resolver for text styles, used to obtain leader styles.\n * @param scaleFactor - The scale factor to apply to leader dimensions, usually comes from the `scaleFactor` of a [[Drawing]] element.\n * @returns `true` if at least one leader with a terminator was successfully appended; otherwise, `false`.\n * @beta\n */\nexport function appendLeadersToBuilder(builder: ElementGeometry.Builder, leaders: TextAnnotationLeader[], layout: TextBlockLayout, transform: Transform, params: GeometryParams, textStyleResolver: TextStyleResolver, scaleFactor: number): boolean {\n let result = true;\n const scaledBlockTextHeight = textStyleResolver.blockSettings.textHeight * scaleFactor;\n let frame: TextFrameStyleProps | undefined = textStyleResolver.blockSettings.frame;\n\n // If there is no frame, use a rectangular frame to compute the attachmentPoints for leaders.\n if (frame === undefined || frame.shape === \"none\") {\n frame = { shape: \"rectangle\" }\n }\n if (frame.shape === undefined || frame.shape === \"none\") return false;\n const frameCurve = computeFrame({ frame: frame.shape, range: layout.range, transform });\n\n for (const leader of leaders) {\n const leaderStyle = textStyleResolver.resolveSettings(leader.styleOverrides ?? {}, true);\n\n let effectiveColor: TextStyleColor = \"subcategory\";\n\n if (leaderStyle.leader.color === \"inherit\") {\n effectiveColor = leaderStyle.color;\n } else if (leaderStyle.leader.color !== \"subcategory\") {\n effectiveColor = leaderStyle.leader.color;\n }\n\n if (effectiveColor !== \"subcategory\") {\n params.lineColor = ColorDef.fromJSON(effectiveColor);\n result = result && builder.appendGeometryParamsChange(params);\n }\n\n const attachmentPoint = computeLeaderAttachmentPoint(leader, frameCurve, layout, transform);\n if (!attachmentPoint) return false;\n\n // Leader line geometry\n const leaderLinePoints: Point3d[] = [];\n\n leaderLinePoints.push(leader.startPoint)\n\n leader.intermediatePoints?.forEach((point) => {\n leaderLinePoints.push(point);\n });\n\n if (leaderStyle.leader.wantElbow) {\n const elbowLength = leaderStyle.leader.elbowLength * scaledBlockTextHeight;\n const elbowDirection = computeElbowDirection(attachmentPoint, frameCurve, elbowLength);\n if (elbowDirection)\n leaderLinePoints.push(attachmentPoint.plusScaled(elbowDirection, elbowLength))\n }\n\n leaderLinePoints.push(attachmentPoint)\n\n result = result && builder.appendGeometryQuery(LineString3d.create(leaderLinePoints));\n\n // Terminator geometry\n const terminatorDirection = Vector3d.createStartEnd(\n leaderLinePoints[0], leaderLinePoints[1]\n ).normalize();\n\n const termY = terminatorDirection?.unitCrossProduct(Vector3d.unitZ());\n if (!termY || !terminatorDirection) continue; // Assuming leaders without terminators is a valid case.\n const terminatorHeight = leaderStyle.leader.terminatorHeightFactor * scaledBlockTextHeight;\n const terminatorWidth = leaderStyle.leader.terminatorWidthFactor * scaledBlockTextHeight;\n const basePoint = leader.startPoint.plusScaled(terminatorDirection, terminatorWidth);\n const termPointA = basePoint.plusScaled(termY, terminatorHeight);\n const termPointB = basePoint.plusScaled(termY.negate(), terminatorHeight);\n result = result && builder.appendGeometryQuery(LineString3d.create([termPointA, leader.startPoint, termPointB]));\n\n }\n return result;\n}\n\n\n/**\n * Computes the direction vector for an \"elbow\" for leader based on the attachment point and a frame curve.\n * The elbow direction is determined by whether the attachment point is closer to the left or right side of the frame.\n * If the computed elbow would be tangent to the frame at the intersection, no elbow direction is returned.\n *\n * @param attachmentPoint - The point where the leader attaches.\n * @param frameCurve - The frame curve (either a Loop or Path) to which the leader is attached.\n * @param elbowLength - The length of the elbow segment to be created.\n * @returns The direction vector for the elbow, or `undefined` if the elbow would be tangent to the frame.\n * @beta\n */\nexport function computeElbowDirection(attachmentPoint: Point3d, frameCurve: Loop | Path, elbowLength: number): Vector3d | undefined {\n\n let elbowDirection: Vector3d | undefined;\n // Determine the direction based on the closest point's position relative to the frame\n const isCloserToLeft = Math.abs(attachmentPoint.x - frameCurve.range().low.x) < Math.abs(attachmentPoint.x - frameCurve.range().high.x);\n\n // Decide the direction: left (-X) or right (+X)\n elbowDirection = isCloserToLeft ? Vector3d.unitX().negate() : Vector3d.unitX();\n\n // Verify if the elbow is a tangent to the frame, if yes, do not create an elbow\n const elbowPoint = attachmentPoint.plusScaled(elbowDirection, elbowLength);\n const elbowLine = LineSegment3d.create(attachmentPoint, elbowPoint);\n // Find intersection points between the elbow and the frame\n const intersections = CurveCurve.intersectionXYZPairs(elbowLine, false, frameCurve, false);\n // As the elbow will intersect the frame only at one point, we can safely use the first intersection\n const intersection = intersections[0];\n const curveFraction = intersection.detailB.fraction;\n const derivative = intersection.detailB.curve?.fractionToPointAndDerivative(curveFraction);\n const tangent = derivative?.direction.normalize();\n const lineDirection = Vector3d.createStartEnd(elbowLine.point0Ref, elbowLine.point1Ref).normalize();\n if (tangent && lineDirection) {\n const dot = tangent.dotProduct(lineDirection);\n // If the tangent and line direction are aligned (dot product close to 1 or -1), it's tangent\n if (Math.abs(dot) > 0.999) {\n elbowDirection = undefined;\n }\n }\n return elbowDirection;\n}\n\n/**\n * Computes the attachment point for a leader line on a text annotation frame.\n *\n * The attachment point is determined based on the leader's attachment mode:\n * - `\"Nearest\"`: Finds the closest point on the frame curve to the leader's start point.\n * - `\"KeyPoint\"`: Uses a specific curve segment and fraction along that segment to determine the point.\n * - `\"TextPoint\"`: Calculates a point on the text layout (top/bottom, left/right) and projects it onto the frame curve.\n *\n * @param leader - The leader props.\n * @param frameCurve - The curve (Loop or Path) representing the annotation frame.\n * @param textLayout - The layout information for the text block.\n * @param transform - The transform applied to the text layout.\n * @returns The computed attachment point as a `Point3d`, or `undefined` if it cannot be determined.\n * @beta\n */\nexport function computeLeaderAttachmentPoint(\n leader: TextAnnotationLeader,\n frameCurve: Loop | Path,\n textLayout: TextBlockLayout,\n transform: Transform\n): Point3d | undefined {\n let attachmentPoint: Point3d | undefined;\n\n if (leader.attachment.mode === \"Nearest\") {\n attachmentPoint = frameCurve.closestPoint(leader.startPoint)?.point;\n } else if (leader.attachment.mode === \"KeyPoint\") {\n const curves = frameCurve.collectCurvePrimitives(undefined, false, true);\n const curveIndex = leader.attachment.curveIndex;\n const fraction = leader.attachment.fraction;\n if (curveIndex >= curves.length) {\n // If the curveIndex is invalid, use the last curve\n // This is a fallback to avoid out-of-bounds access\n attachmentPoint = curves[curves.length - 1].fractionToPoint(fraction);\n } else {\n attachmentPoint = curves[curveIndex].fractionToPoint(fraction);\n }\n } else { // attachment.mode=\"TextPoint\"\n let scaleDirection = transform.matrix.getColumn(0).negate(); // direction to draw a scaled line from text attachment point to find intersection point on frame\n let lineIndex: number;\n if (leader.attachment.position.includes(\"Top\")) {\n lineIndex = 0\n } else {\n lineIndex = textLayout.lines.length - 1\n }\n const lineRange = textLayout.lines[lineIndex].range;\n const lineOffset = textLayout.lines[lineIndex].offsetFromDocument;\n const origin = transform.multiplyPoint3d(Point3d.fromJSON(lineOffset));\n let attachmentPointOnText = origin.plusScaled(transform.matrix.getColumn(1), ((lineRange.yLength()) / 2));\n\n if (leader.attachment.position.includes(\"Right\")) {\n attachmentPointOnText = attachmentPointOnText.plusScaled(transform.matrix.getColumn(0), lineRange.xLength());\n scaleDirection = scaleDirection.negate();\n }\n // Find the nearest intersection point on the frame to get the correct attachment point\n // Extend the direction vector to create a target point far along the direction\n const targetPoint = attachmentPointOnText.plusScaled(scaleDirection, 1e6); // Scale the direction vector to a large value\n const intersectionLine = LineSegment3d.create(attachmentPointOnText, targetPoint);\n const closestPointDetail = CurveCurve.intersectionXYZPairs(intersectionLine, false, frameCurve, false);\n attachmentPoint = closestPointDetail[0]?.detailA.point;\n }\n return attachmentPoint;\n}"]}
|
|
@@ -16,11 +16,11 @@ function setColor(color, context) {
|
|
|
16
16
|
}
|
|
17
17
|
function createTextString(text, run, origin) {
|
|
18
18
|
assert(text.length > 0);
|
|
19
|
-
const {
|
|
19
|
+
const { textHeight, widthFactor, isBold, isItalic, isUnderlined } = run.style;
|
|
20
20
|
return new TextString({
|
|
21
21
|
text,
|
|
22
22
|
font: run.fontId,
|
|
23
|
-
height:
|
|
23
|
+
height: textHeight,
|
|
24
24
|
widthFactor,
|
|
25
25
|
bold: isBold,
|
|
26
26
|
italic: isItalic,
|
|
@@ -71,7 +71,7 @@ function processFractionRun(run, transform, context) {
|
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
assert(undefined !== run.numeratorRange && undefined !== run.denominatorRange);
|
|
74
|
-
const fontSize = new Vector2d(run.style.
|
|
74
|
+
const fontSize = new Vector2d(run.style.textHeight * run.style.widthFactor, run.style.textHeight);
|
|
75
75
|
fontSize.scale(run.style.stackedFractionScale, fontSize);
|
|
76
76
|
const numeratorOffset = new Point3d(run.numeratorRange.low.x, run.numeratorRange.low.y, 0);
|
|
77
77
|
const denominatorOffset = new Point3d(run.denominatorRange.low.x, run.denominatorRange.low.y, 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextBlockGeometry.js","sourceRoot":"","sources":["../../../src/annotations/TextBlockGeometry.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAuD,UAAU,EAAkB,MAAM,oBAAoB,CAAC;AAErH,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC5F,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAO7C,SAAS,QAAQ,CAAC,KAAqB,EAAE,OAAwB;IAC/D,IAAI,KAAK,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC/B,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC;QACzB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAClC,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY,EAAE,GAAc,EAAE,MAAgB;IACtE,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAExB,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC;IAE9E,OAAO,IAAI,UAAU,CAAC;QACpB,IAAI;QACJ,IAAI,EAAE,GAAG,CAAC,MAAM;QAChB,MAAM,EAAE,UAAU;QAClB,WAAW;QACX,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,YAAY;QACvB,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAED,SAAS,cAAc,CAAC,GAAc,EAAE,SAAoB,EAAE,OAAwB;IACpF,MAAM,CAAC,GAAG,CA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AAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC/B,cAAc,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YACzC,CAAC;iBAAM,IAAI,UAAU,KAAK,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC1C,kBAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC7C,CAAC;iBAAM,CAAC;gBACN,eAAe,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;AACtC,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 ElementGeometry\n */\n\nimport { TextBlockGeometryProps, TextBlockGeometryPropsEntry, TextString, TextStyleColor } from \"@itwin/core-common\";\nimport { RunLayout, TextBlockLayout } from \"./TextBlockLayout\";\nimport { LineSegment3d, Point3d, Range2d, Transform, Vector2d } from \"@itwin/core-geometry\";\nimport { assert } from \"@itwin/core-bentley\";\n\ninterface GeometryContext {\n curColor?: TextStyleColor;\n entries: TextBlockGeometryPropsEntry[];\n}\n\nfunction setColor(color: TextStyleColor, context: GeometryContext): void {\n if (color !== context.curColor) {\n context.curColor = color;\n context.entries.push({ color });\n }\n}\n\nfunction createTextString(text: string, run: RunLayout, origin?: Point3d): TextString {\n assert(text.length > 0);\n\n const { lineHeight, widthFactor, isBold, isItalic, isUnderlined } = run.style;\n\n return new TextString({\n text,\n font: run.fontId,\n height: lineHeight,\n widthFactor,\n bold: isBold,\n italic: isItalic,\n underline: isUnderlined,\n origin,\n });\n}\n\nfunction processTextRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\n assert(run.source.type === \"text\");\n const text = run.source.content.substring(run.charOffset, run.charOffset + run.numChars);\n if (text.length === 0) {\n return;\n }\n\n const ts = createTextString(text, run);\n if (\"none\" !== run.source.baselineShift) {\n const isSub = \"subscript\" === run.source.baselineShift;\n const offsetFactor = run.style[isSub ? \"subScriptOffsetFactor\" : \"superScriptOffsetFactor\"];\n const scale = run.style[isSub ? \"subScriptScale\" : \"superScriptScale\"];\n\n ts.origin.y += offsetFactor * ts.height;\n ts.height *= scale;\n }\n\n ts.transformInPlace(transform);\n\n setColor(run.style.color, context);\n context.entries.push({ text: ts });\n}\n\nfunction processFieldRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\n assert(run.source.type === \"field\");\n const text = run.source.cachedContent.substring(run.charOffset, run.charOffset + run.numChars);\n if (text.length === 0) {\n return;\n }\n\n const ts = createTextString(text, run);\n ts.transformInPlace(transform);\n\n setColor(run.style.color, context);\n context.entries.push({ text: ts });\n}\n\nfunction createFractionTextString(text: string, run: RunLayout, origin: Point3d, transform: Transform): TextString {\n const ts = createTextString(text, run, origin);\n assert(undefined !== ts.widthFactor);\n\n ts.height *= run.style.stackedFractionScale;\n\n ts.transformInPlace(transform);\n\n return ts;\n}\n\nfunction processFractionRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\n const source = run.source;\n assert(source.type === \"fraction\");\n\n if (source.numerator.length === 0 && source.denominator.length === 0) {\n return;\n }\n\n assert(undefined !== run.numeratorRange && undefined !== run.denominatorRange);\n\n const fontSize = new Vector2d(run.style.lineHeight * run.style.widthFactor, run.style.lineHeight);\n fontSize.scale(run.style.stackedFractionScale, fontSize);\n\n const numeratorOffset = new Point3d(run.numeratorRange.low.x, run.numeratorRange.low.y, 0);\n const denominatorOffset = new Point3d(run.denominatorRange.low.x, run.denominatorRange.low.y, 0);\n\n setColor(run.style.color, context);\n\n if (source.numerator.length > 0) {\n context.entries.push({ text: createFractionTextString(source.numerator, run, numeratorOffset, transform) });\n }\n\n const numeratorRange = Range2d.fromJSON(run.numeratorRange);\n const denominatorRange = Range2d.fromJSON(run.denominatorRange);\n\n let separator: LineSegment3d;\n if (run.style.stackedFractionType === \"horizontal\") {\n const fractionWidth = Math.max(numeratorRange.xLength(), denominatorRange.xLength());\n const y = 1.25 * denominatorRange.yLength();\n separator = LineSegment3d.createXYXY(0, y, fractionWidth, y);\n } else {\n const p0 = new Point3d(denominatorRange.low.x - fontSize.x / 2, denominatorRange.low.y + fontSize.y * (1 / 3), 0);\n const p1 = new Point3d(p0.x + fontSize.x, p0.y + fontSize.y * 1.5, 0);\n separator = LineSegment3d.createCapture(p0, p1);\n }\n\n separator.tryTransformInPlace(transform);\n\n context.entries.push({\n separator: {\n startPoint: separator.point0Ref.toJSON(),\n endPoint: separator.point1Ref.toJSON(),\n },\n });\n\n if (source.denominator.length > 0) {\n context.entries.push({ text: createFractionTextString(source.denominator, run, denominatorOffset, transform) });\n }\n}\n\n/**\n * Produces the geometry for a text block in a way that can be interpreted by a [[GeometryStreamBuilder]] or [[ElementBuilder.Geometry]].\n * To build the geometry for a whole [[TextAnnotation]], use [[appendTextAnnotationGeometry]] instead.\n * @param layout of the text block as computed by [[layoutTextBlock]].\n * @param documentTransform that positions the text block in world coordinates.\n * @returns TextBlockGeometryProps.\n * @beta\n */\nexport function produceTextBlockGeometry(layout: TextBlockLayout, documentTransform: Transform): TextBlockGeometryProps {\n const context: GeometryContext = { entries: [] };\n for (const line of layout.lines) {\n const lineTrans = Transform.createTranslationXYZ(line.offsetFromDocument.x, line.offsetFromDocument.y, 0);\n\n // Create geometry for list markers if present\n if (line.marker) {\n const markerTrans = Transform.createTranslationXYZ(line.marker.offsetFromLine.x, line.marker.offsetFromLine.y, 0);\n lineTrans.multiplyTransformTransform(markerTrans, markerTrans);\n documentTransform.multiplyTransformTransform(markerTrans, markerTrans);\n\n processTextRun(line.marker, markerTrans, context);\n }\n\n // Create geometry for runs\n for (const run of line.runs) {\n // Skip runs that are solely whitespace\n if (run.source.isWhitespace) {\n continue;\n }\n\n const runTrans = Transform.createTranslationXYZ(run.offsetFromLine.x, run.offsetFromLine.y, 0);\n lineTrans.multiplyTransformTransform(runTrans, runTrans);\n documentTransform.multiplyTransformTransform(runTrans, runTrans);\n if (\"text\" === run.source.type) {\n processTextRun(run, runTrans, context);\n } else if (\"fraction\" === run.source.type) {\n processFractionRun(run, runTrans, context);\n } else {\n processFieldRun(run, runTrans, context);\n }\n }\n }\n\n return { entries: context.entries };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TextBlockGeometry.js","sourceRoot":"","sources":["../../../src/annotations/TextBlockGeometry.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAuD,UAAU,EAAkB,MAAM,oBAAoB,CAAC;AAErH,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC5F,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAO7C,SAAS,QAAQ,CAAC,KAAqB,EAAE,OAAwB;IAC/D,IAAI,KAAK,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC/B,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC;QACzB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAClC,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY,EAAE,GAAc,EAAE,MAAgB;IACtE,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAExB,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC;IAE9E,OAAO,IAAI,UAAU,CAAC;QACpB,IAAI;QACJ,IAAI,EAAE,GAAG,CAAC,MAAM;QAChB,MAAM,EAAE,UAAU;QAClB,WAAW;QACX,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,QAAQ;QAChB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,0BAA0B,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACzD,iBAAiB,CAAC,0BAA0B,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACjE,IAAI,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC/B,cAAc,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YACzC,CAAC;iBAAM,IAAI,UAAU,KAAK,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC1C,kBAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC7C,CAAC;iBAAM,CAAC;gBACN,eAAe,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;AACtC,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 ElementGeometry\n */\n\nimport { TextBlockGeometryProps, TextBlockGeometryPropsEntry, TextString, TextStyleColor } from \"@itwin/core-common\";\nimport { RunLayout, TextBlockLayout } from \"./TextBlockLayout\";\nimport { LineSegment3d, Point3d, Range2d, Transform, Vector2d } from \"@itwin/core-geometry\";\nimport { assert } from \"@itwin/core-bentley\";\n\ninterface GeometryContext {\n curColor?: TextStyleColor;\n entries: TextBlockGeometryPropsEntry[];\n}\n\nfunction setColor(color: TextStyleColor, context: GeometryContext): void {\n if (color !== context.curColor) {\n context.curColor = color;\n context.entries.push({ color });\n }\n}\n\nfunction createTextString(text: string, run: RunLayout, origin?: Point3d): TextString {\n assert(text.length > 0);\n\n const { textHeight, widthFactor, isBold, isItalic, isUnderlined } = run.style;\n\n return new TextString({\n text,\n font: run.fontId,\n height: textHeight,\n widthFactor,\n bold: isBold,\n italic: isItalic,\n underline: isUnderlined,\n origin,\n });\n}\n\nfunction processTextRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\n assert(run.source.type === \"text\");\n const text = run.source.content.substring(run.charOffset, run.charOffset + run.numChars);\n if (text.length === 0) {\n return;\n }\n\n const ts = createTextString(text, run);\n if (\"none\" !== run.source.baselineShift) {\n const isSub = \"subscript\" === run.source.baselineShift;\n const offsetFactor = run.style[isSub ? \"subScriptOffsetFactor\" : \"superScriptOffsetFactor\"];\n const scale = run.style[isSub ? \"subScriptScale\" : \"superScriptScale\"];\n\n ts.origin.y += offsetFactor * ts.height;\n ts.height *= scale;\n }\n\n ts.transformInPlace(transform);\n\n setColor(run.style.color, context);\n context.entries.push({ text: ts });\n}\n\nfunction processFieldRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\n assert(run.source.type === \"field\");\n const text = run.source.cachedContent.substring(run.charOffset, run.charOffset + run.numChars);\n if (text.length === 0) {\n return;\n }\n\n const ts = createTextString(text, run);\n ts.transformInPlace(transform);\n\n setColor(run.style.color, context);\n context.entries.push({ text: ts });\n}\n\nfunction createFractionTextString(text: string, run: RunLayout, origin: Point3d, transform: Transform): TextString {\n const ts = createTextString(text, run, origin);\n assert(undefined !== ts.widthFactor);\n\n ts.height *= run.style.stackedFractionScale;\n\n ts.transformInPlace(transform);\n\n return ts;\n}\n\nfunction processFractionRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\n const source = run.source;\n assert(source.type === \"fraction\");\n\n if (source.numerator.length === 0 && source.denominator.length === 0) {\n return;\n }\n\n assert(undefined !== run.numeratorRange && undefined !== run.denominatorRange);\n\n const fontSize = new Vector2d(run.style.textHeight * run.style.widthFactor, run.style.textHeight);\n fontSize.scale(run.style.stackedFractionScale, fontSize);\n\n const numeratorOffset = new Point3d(run.numeratorRange.low.x, run.numeratorRange.low.y, 0);\n const denominatorOffset = new Point3d(run.denominatorRange.low.x, run.denominatorRange.low.y, 0);\n\n setColor(run.style.color, context);\n\n if (source.numerator.length > 0) {\n context.entries.push({ text: createFractionTextString(source.numerator, run, numeratorOffset, transform) });\n }\n\n const numeratorRange = Range2d.fromJSON(run.numeratorRange);\n const denominatorRange = Range2d.fromJSON(run.denominatorRange);\n\n let separator: LineSegment3d;\n if (run.style.stackedFractionType === \"horizontal\") {\n const fractionWidth = Math.max(numeratorRange.xLength(), denominatorRange.xLength());\n const y = 1.25 * denominatorRange.yLength();\n separator = LineSegment3d.createXYXY(0, y, fractionWidth, y);\n } else {\n const p0 = new Point3d(denominatorRange.low.x - fontSize.x / 2, denominatorRange.low.y + fontSize.y * (1 / 3), 0);\n const p1 = new Point3d(p0.x + fontSize.x, p0.y + fontSize.y * 1.5, 0);\n separator = LineSegment3d.createCapture(p0, p1);\n }\n\n separator.tryTransformInPlace(transform);\n\n context.entries.push({\n separator: {\n startPoint: separator.point0Ref.toJSON(),\n endPoint: separator.point1Ref.toJSON(),\n },\n });\n\n if (source.denominator.length > 0) {\n context.entries.push({ text: createFractionTextString(source.denominator, run, denominatorOffset, transform) });\n }\n}\n\n/**\n * Produces the geometry for a text block in a way that can be interpreted by a [[GeometryStreamBuilder]] or [[ElementBuilder.Geometry]].\n * To build the geometry for a whole [[TextAnnotation]], use [[appendTextAnnotationGeometry]] instead.\n * @param layout of the text block as computed by [[layoutTextBlock]].\n * @param documentTransform that positions the text block in world coordinates.\n * @returns TextBlockGeometryProps.\n * @beta\n */\nexport function produceTextBlockGeometry(layout: TextBlockLayout, documentTransform: Transform): TextBlockGeometryProps {\n const context: GeometryContext = { entries: [] };\n for (const line of layout.lines) {\n const lineTrans = Transform.createTranslationXYZ(line.offsetFromDocument.x, line.offsetFromDocument.y, 0);\n\n // Create geometry for list markers if present\n if (line.marker) {\n const markerTrans = Transform.createTranslationXYZ(line.marker.offsetFromLine.x, line.marker.offsetFromLine.y, 0);\n lineTrans.multiplyTransformTransform(markerTrans, markerTrans);\n documentTransform.multiplyTransformTransform(markerTrans, markerTrans);\n\n processTextRun(line.marker, markerTrans, context);\n }\n\n // Create geometry for runs\n for (const run of line.runs) {\n // Skip runs that are solely whitespace\n if (run.source.isWhitespace) {\n continue;\n }\n\n const runTrans = Transform.createTranslationXYZ(run.offsetFromLine.x, run.offsetFromLine.y, 0);\n lineTrans.multiplyTransformTransform(runTrans, runTrans);\n documentTransform.multiplyTransformTransform(runTrans, runTrans);\n if (\"text\" === run.source.type) {\n processTextRun(run, runTrans, context);\n } else if (\"fraction\" === run.source.type) {\n processFractionRun(run, runTrans, context);\n } else {\n processFieldRun(run, runTrans, context);\n }\n }\n }\n\n return { entries: context.entries };\n}\n"]}
|
|
@@ -20,7 +20,7 @@ export interface ComputeRangesForTextLayoutArgs {
|
|
|
20
20
|
baselineShift: BaselineShift;
|
|
21
21
|
fontId: FontId;
|
|
22
22
|
widthFactor: number;
|
|
23
|
-
|
|
23
|
+
textHeight: number;
|
|
24
24
|
}
|
|
25
25
|
/** A function that uses a font to compute the layout and justification ranges of a string of text.
|
|
26
26
|
* @internal
|
|
@@ -130,7 +130,7 @@ declare class LayoutContext {
|
|
|
130
130
|
private readonly _findFontId;
|
|
131
131
|
private readonly _fontIds;
|
|
132
132
|
constructor(textStyleResolver: TextStyleResolver, _computeTextRange: ComputeRangesForTextLayout, _findFontId: FindFontId);
|
|
133
|
-
findFontId(name: string): FontId;
|
|
133
|
+
findFontId(name: string, type?: FontType): FontId;
|
|
134
134
|
computeRangeForText(chars: string, style: TextStyleSettings, baselineShift: BaselineShift): TextLayoutRanges;
|
|
135
135
|
computeRangeForTextRun(style: TextStyleSettings, run: TextRun | FieldRun, charOffset: number, numChars: number): TextLayoutRanges;
|
|
136
136
|
computeRangeForFractionRun(style: TextStyleSettings, source: FractionRun): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextBlockLayout.d.ts","sourceRoot":"","sources":["../../../src/annotations/TextBlockLayout.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAA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IAiBrB,OAAO,CAAC,iBAAiB;IAkFzB,OAAO,CAAC,WAAW;IAwCnB,OAAO,CAAC,SAAS;IA2CjB,OAAO,CAAC,YAAY;IA6BpB,OAAO,CAAC,YAAY;CAoBrB"}
|
|
@@ -73,7 +73,7 @@ function scaleRange(range, scale) {
|
|
|
73
73
|
range.high.scaleInPlace(scale);
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
|
-
* Applies block level settings (lineSpacingFactor,
|
|
76
|
+
* Applies block level settings (lineSpacingFactor, paragraphSpacingFactor, widthFactor, frame, margins, justification, and leader) to a [TextStyleSettings]($common).
|
|
77
77
|
* These must be set on the block, as they are meaningless on individual paragraphs/runs.
|
|
78
78
|
* However, leaders are a special case and can override the block's leader settings.
|
|
79
79
|
* Setting `isLeader` to `true` makes the [TextBlock]($common) settings not override the leader's settings.
|
|
@@ -84,21 +84,27 @@ function applyBlockSettings(target, source, isLeader = false) {
|
|
|
84
84
|
return target;
|
|
85
85
|
}
|
|
86
86
|
const lineSpacingFactor = source.lineSpacingFactor ?? target.lineSpacingFactor;
|
|
87
|
-
const
|
|
87
|
+
const paragraphSpacingFactor = source.paragraphSpacingFactor ?? target.paragraphSpacingFactor;
|
|
88
88
|
const widthFactor = source.widthFactor ?? target.widthFactor;
|
|
89
|
+
const justification = source.justification ?? target.justification;
|
|
89
90
|
const frame = source.frame ?? target.frame;
|
|
91
|
+
const margins = source.margins ?? target.margins;
|
|
90
92
|
const leader = source.leader ?? target.leader;
|
|
91
93
|
const leaderShouldChange = !isLeader && !target.leaderEquals(leader);
|
|
92
94
|
if (lineSpacingFactor !== target.lineSpacingFactor ||
|
|
93
|
-
|
|
95
|
+
paragraphSpacingFactor !== target.paragraphSpacingFactor ||
|
|
94
96
|
widthFactor !== target.widthFactor ||
|
|
97
|
+
justification !== target.justification ||
|
|
95
98
|
!target.frameEquals(frame) ||
|
|
99
|
+
!target.marginsEqual(margins) ||
|
|
96
100
|
leaderShouldChange) {
|
|
97
101
|
const cloneProps = {
|
|
98
102
|
lineSpacingFactor,
|
|
99
|
-
|
|
103
|
+
paragraphSpacingFactor,
|
|
100
104
|
widthFactor,
|
|
105
|
+
justification,
|
|
101
106
|
frame,
|
|
107
|
+
margins,
|
|
102
108
|
};
|
|
103
109
|
if (leaderShouldChange) {
|
|
104
110
|
cloneProps.leader = leader;
|
|
@@ -153,35 +159,35 @@ class LayoutContext {
|
|
|
153
159
|
this._computeTextRange = _computeTextRange;
|
|
154
160
|
this._findFontId = _findFontId;
|
|
155
161
|
}
|
|
156
|
-
findFontId(name) {
|
|
162
|
+
findFontId(name, type) {
|
|
157
163
|
let fontId = this._fontIds.get(name);
|
|
158
164
|
if (undefined === fontId) {
|
|
159
|
-
this._fontIds.set(name, fontId = this._findFontId(name));
|
|
165
|
+
this._fontIds.set(name, fontId = this._findFontId(name, type));
|
|
160
166
|
}
|
|
161
167
|
return fontId;
|
|
162
168
|
}
|
|
163
169
|
computeRangeForText(chars, style, baselineShift) {
|
|
164
170
|
if (chars.length === 0) {
|
|
165
171
|
return {
|
|
166
|
-
layout: new Range2d(0, 0, 0, style.
|
|
172
|
+
layout: new Range2d(0, 0, 0, style.textHeight),
|
|
167
173
|
justification: new Range2d(),
|
|
168
174
|
};
|
|
169
175
|
}
|
|
170
|
-
const fontId = this.findFontId(style.
|
|
176
|
+
const fontId = this.findFontId(style.font.name, style.font.type);
|
|
171
177
|
const { layout, justification } = this._computeTextRange({
|
|
172
178
|
chars,
|
|
173
179
|
fontId,
|
|
174
180
|
baselineShift,
|
|
175
181
|
bold: style.isBold,
|
|
176
182
|
italic: style.isItalic,
|
|
177
|
-
|
|
183
|
+
textHeight: style.textHeight,
|
|
178
184
|
widthFactor: this.textStyleResolver.blockSettings.widthFactor,
|
|
179
185
|
});
|
|
180
186
|
if ("none" !== baselineShift) {
|
|
181
187
|
const isSub = "subscript" === baselineShift;
|
|
182
188
|
const scale = isSub ? style.subScriptScale : style.superScriptScale;
|
|
183
189
|
const offsetFactor = isSub ? style.subScriptOffsetFactor : style.superScriptOffsetFactor;
|
|
184
|
-
const offset = { x: 0, y: style.
|
|
190
|
+
const offset = { x: 0, y: style.textHeight * offsetFactor };
|
|
185
191
|
scaleRange(layout, scale);
|
|
186
192
|
layout.cloneTranslated(offset, layout);
|
|
187
193
|
scaleRange(justification, scale);
|
|
@@ -233,7 +239,7 @@ class LayoutContext {
|
|
|
233
239
|
computeRangeForTabRun(style, source, lengthFromLastTab) {
|
|
234
240
|
const interval = source.styleOverrides.tabInterval ?? style.tabInterval;
|
|
235
241
|
const tabEndX = interval - lengthFromLastTab % interval;
|
|
236
|
-
const range = new Range2d(0, 0, 0, style.
|
|
242
|
+
const range = new Range2d(0, 0, 0, style.textHeight);
|
|
237
243
|
range.extendXY(tabEndX, range.low.y);
|
|
238
244
|
return range;
|
|
239
245
|
}
|
|
@@ -290,7 +296,7 @@ export class RunLayout {
|
|
|
290
296
|
}
|
|
291
297
|
static create(source, context, cumulativeOverrides) {
|
|
292
298
|
const style = context.textStyleResolver.resolveSettings(cumulativeOverrides);
|
|
293
|
-
const fontId = context.findFontId(style.
|
|
299
|
+
const fontId = context.findFontId(style.font.name, style.font.type);
|
|
294
300
|
const charOffset = 0;
|
|
295
301
|
const offsetFromLine = { x: 0, y: 0 };
|
|
296
302
|
let numChars = 0;
|
|
@@ -316,7 +322,7 @@ export class RunLayout {
|
|
|
316
322
|
default: { // "linebreak" or "tab"
|
|
317
323
|
// "tab": Tabs rely on the context they are in, so we compute its range later.
|
|
318
324
|
// lineBreak: We do this so that blank lines space correctly without special casing later.
|
|
319
|
-
range = new Range2d(0, 0, 0, style.
|
|
325
|
+
range = new Range2d(0, 0, 0, style.textHeight);
|
|
320
326
|
break;
|
|
321
327
|
}
|
|
322
328
|
}
|
|
@@ -429,15 +435,36 @@ export class LineLayout {
|
|
|
429
435
|
this.runRange.low.setZero();
|
|
430
436
|
this.runRange.high.setZero();
|
|
431
437
|
this.lengthFromLastTab = 0;
|
|
432
|
-
// Some runs (fractions) are taller than others.
|
|
433
|
-
// We want to center each run vertically inside the line.
|
|
434
438
|
let lineHeight = 0;
|
|
439
|
+
let tallestNonFractionRun;
|
|
435
440
|
for (const run of this._runs) {
|
|
436
|
-
|
|
441
|
+
const runHeight = run.range.yLength();
|
|
442
|
+
lineHeight = Math.max(lineHeight, runHeight);
|
|
443
|
+
if (run.source.type !== "fraction" && (!tallestNonFractionRun || runHeight > tallestNonFractionRun.range.yLength())) {
|
|
444
|
+
tallestNonFractionRun = run;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
// // The baseline for the line is the bottom of the tallest non-fraction run, centered in the line.
|
|
448
|
+
let baseline = 0;
|
|
449
|
+
if (tallestNonFractionRun) {
|
|
450
|
+
baseline = (lineHeight + tallestNonFractionRun.range.yLength()) / 2;
|
|
437
451
|
}
|
|
438
452
|
for (const run of this._runs) {
|
|
439
453
|
const runHeight = run.range.yLength();
|
|
440
|
-
|
|
454
|
+
// Vertically align runs: normal text at baseline, fractions visually centered on text or line as appropriate.
|
|
455
|
+
let yOffset = lineHeight - baseline;
|
|
456
|
+
if (run.source.type === "fraction") {
|
|
457
|
+
const denominatorHeight = run.denominatorRange?.yLength() ?? 0;
|
|
458
|
+
if (tallestNonFractionRun && run.style.textHeight <= tallestNonFractionRun.style.textHeight) {
|
|
459
|
+
// Shift fraction to baseline, then down by half the denominator height so it appears centered relative to any non-fraction text of the same height.
|
|
460
|
+
yOffset = (lineHeight - baseline) - denominatorHeight / 2;
|
|
461
|
+
}
|
|
462
|
+
else {
|
|
463
|
+
// If the fraction text height is greater than the largest non-fraction text, just center it in the line.
|
|
464
|
+
yOffset = (lineHeight - runHeight) / 2;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
const runOffset = { x: this.runRange.high.x, y: yOffset };
|
|
441
468
|
run.offsetFromLine = runOffset;
|
|
442
469
|
const runLayoutRange = run.range.cloneTranslated(runOffset);
|
|
443
470
|
this.runRange.extendRange(runLayoutRange);
|
|
@@ -498,8 +525,8 @@ export class TextBlockLayout {
|
|
|
498
525
|
this.textRange.high.x = source.width;
|
|
499
526
|
}
|
|
500
527
|
this.populateLines(context);
|
|
501
|
-
this.justifyLines();
|
|
502
|
-
this.applyMargins(
|
|
528
|
+
this.justifyLines(context);
|
|
529
|
+
this.applyMargins(context.textStyleResolver.blockSettings.margins);
|
|
503
530
|
}
|
|
504
531
|
toResult() {
|
|
505
532
|
return {
|
|
@@ -638,7 +665,7 @@ export class TextBlockLayout {
|
|
|
638
665
|
}
|
|
639
666
|
if (curLine.source.type !== "linebreak") {
|
|
640
667
|
const newLine = new LineLayout(next, cumulativeOverrides, context, depth);
|
|
641
|
-
newLine.offsetFromDocument.y -= context.textStyleResolver.blockSettings.paragraphSpacingFactor * context.textStyleResolver.blockSettings.
|
|
668
|
+
newLine.offsetFromDocument.y -= context.textStyleResolver.blockSettings.paragraphSpacingFactor * context.textStyleResolver.blockSettings.textHeight;
|
|
642
669
|
return newLine;
|
|
643
670
|
}
|
|
644
671
|
const run = curLine.source.clone();
|
|
@@ -650,7 +677,7 @@ export class TextBlockLayout {
|
|
|
650
677
|
// Place it below any existing lines
|
|
651
678
|
if (this.lines.length > 0) {
|
|
652
679
|
lineOffset.y += this._back.offsetFromDocument.y;
|
|
653
|
-
lineOffset.y -= context.textStyleResolver.blockSettings.lineSpacingFactor * context.textStyleResolver.blockSettings.
|
|
680
|
+
lineOffset.y -= context.textStyleResolver.blockSettings.lineSpacingFactor * context.textStyleResolver.blockSettings.textHeight;
|
|
654
681
|
}
|
|
655
682
|
curLine.offsetFromDocument = lineOffset;
|
|
656
683
|
// Update document range from computed line range and position
|
|
@@ -658,14 +685,14 @@ export class TextBlockLayout {
|
|
|
658
685
|
this.lines.push(curLine);
|
|
659
686
|
if (newParagraph) {
|
|
660
687
|
const newLine = new LineLayout(next, cumulativeOverrides, context, depth);
|
|
661
|
-
newLine.offsetFromDocument.y -= context.textStyleResolver.blockSettings.paragraphSpacingFactor * context.textStyleResolver.blockSettings.
|
|
688
|
+
newLine.offsetFromDocument.y -= context.textStyleResolver.blockSettings.paragraphSpacingFactor * context.textStyleResolver.blockSettings.textHeight;
|
|
662
689
|
return newLine;
|
|
663
690
|
}
|
|
664
691
|
return new LineLayout(next, cumulativeOverrides, context, depth);
|
|
665
692
|
}
|
|
666
|
-
justifyLines() {
|
|
693
|
+
justifyLines(context) {
|
|
667
694
|
// We don't want to justify empty text, or a single line of text whose width is 0. By default text is already left justified.
|
|
668
|
-
if (this.lines.length < 1 || (this.lines.length === 1 && this.source.width === 0) || "left" ===
|
|
695
|
+
if (this.lines.length < 1 || (this.lines.length === 1 && this.source.width === 0) || "left" === context.textStyleResolver.blockSettings.justification) {
|
|
669
696
|
return;
|
|
670
697
|
}
|
|
671
698
|
// This is the minimum width of the document's bounding box.
|
|
@@ -674,7 +701,7 @@ export class TextBlockLayout {
|
|
|
674
701
|
for (const line of this.lines) {
|
|
675
702
|
const lineWidth = line.justificationRange.xLength() + line.offsetFromDocument.x;
|
|
676
703
|
let offset = docWidth - lineWidth;
|
|
677
|
-
if ("center" ===
|
|
704
|
+
if ("center" === context.textStyleResolver.blockSettings.justification) {
|
|
678
705
|
offset = offset / 2;
|
|
679
706
|
}
|
|
680
707
|
line.offsetFromDocument.x += offset;
|