@itwin/core-backend 5.4.0-dev.3 → 5.4.0-dev.4
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/annotations/LeaderGeometry.d.ts.map +1 -1
- package/lib/cjs/annotations/LeaderGeometry.js +7 -9
- package/lib/cjs/annotations/LeaderGeometry.js.map +1 -1
- package/lib/cjs/annotations/TextAnnotationElement.d.ts.map +1 -1
- package/lib/cjs/annotations/TextAnnotationElement.js +3 -4
- package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -1
- package/lib/esm/annotations/LeaderGeometry.d.ts.map +1 -1
- package/lib/esm/annotations/LeaderGeometry.js +7 -9
- package/lib/esm/annotations/LeaderGeometry.js.map +1 -1
- package/lib/esm/annotations/TextAnnotationElement.d.ts.map +1 -1
- package/lib/esm/annotations/TextAnnotationElement.js +3 -4
- package/lib/esm/annotations/TextAnnotationElement.js.map +1 -1
- package/lib/esm/test/annotations/LeaderGeometry.test.js +0 -1
- package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
- package/lib/esm/test/annotations/TextAnnotation.test.js +46 -5
- package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
- package/package.json +12 -12
|
@@ -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,EAAmB,WAAW,EAAgG,MAAM,oBAAoB,CAAC;AAC1K,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAkB,aAAa,EAAE,YAAY,EAAE,IAAI,EAAQ,OAAO,EAAa,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACvJ,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,sBAAsB,CAAC,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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, FillDisplay, GeometryParams, TextAnnotationLeader, TextFrameStyleProps, TextStyleColor, TextStyleSettings } from \"@itwin/core-common\";\nimport { Angle, Arc3d, CurveCurve, CurvePrimitive, 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 const terminatorDirection = Vector3d.createStartEnd(\n leaderLinePoints[0], leaderLinePoints[1]\n ).normalize();\n const terminatorWidth = leaderStyle.leader.terminatorWidthFactor * scaledBlockTextHeight;\n // Truncate the first segment of the leader lines to account for the arrowhead size when closedArrow (hollow triangle) terminatorShape is used.\n if (leaderStyle.leader.terminatorShape === \"closedArrow\") {\n if (terminatorDirection)\n leaderLinePoints[0] = leaderLinePoints[0].plusScaled(terminatorDirection, terminatorWidth);\n }\n\n result = result && builder.appendGeometryQuery(LineString3d.create(leaderLinePoints));\n\n if (leaderStyle.leader.terminatorShape !== \"none\") {\n // Terminator geometry\n if (!terminatorDirection) continue; // Assuming leaders without terminators is a valid case.\n result = result && createTerminatorGeometry(builder, leader.startPoint, terminatorDirection, params, leaderStyle, scaledBlockTextHeight);\n\n }\n\n }\n return result;\n}\n\n/**\n * Creates the geometry for a terminator at the end of a leader line.\n * @param builder The geometry builder to append the terminator geometry to.\n * @param point The starting point of the leader line.\n * @param dir The direction vector of the leader line.\n * @param params The geometry parameters to use for the terminator.\n * @param textStyleSettings The text style settings to use for the terminator.\n * @param textHeight The height of the text block.\n * @returns True if the geometry was successfully created, false otherwise.\n * @beta\n */\nexport function createTerminatorGeometry(builder: ElementGeometry.Builder, point: Point3d, dir: Vector3d, params: GeometryParams, textStyleSettings: TextStyleSettings, textHeight: number): boolean {\n\n let result = true;\n const termY = dir.unitCrossProduct(Vector3d.unitZ());\n if (!termY) return false; // If dir is parallel to Z, we can't create a terminator\n const terminatorHeight = textStyleSettings.leader.terminatorHeightFactor * textHeight;\n const terminatorWidth = textStyleSettings.leader.terminatorWidthFactor * textHeight;\n const basePoint = point.plusScaled(dir, terminatorWidth);\n const point1 = basePoint.plusScaled(termY, terminatorHeight / 2);\n const point2 = basePoint.plusScaled(termY.negate(), terminatorHeight / 2);\n const radius = terminatorHeight / 2;\n\n // Helper function to add fill parameters\n const addFillParams = () => {\n params.fillDisplay = FillDisplay.Always;\n result = result && builder.appendGeometryParamsChange(params);\n };\n\n // Helper function to create geometry entry\n const addGeometry = (content: CurvePrimitive, useLoop = false) => {\n const finalContent = useLoop ? Loop.create(content) : content;\n result = result && builder.appendGeometryQuery(finalContent);\n };\n\n switch (textStyleSettings.leader.terminatorShape) {\n case \"openArrow\": {\n const lineString = LineString3d.create([point1, point, point2]);\n addGeometry(lineString);\n break;\n }\n\n case \"closedArrow\": {\n const lineString = LineString3d.create([point1, point, point2, point1]);\n addGeometry(lineString);\n break;\n }\n\n case \"closedArrowFilled\": {\n addFillParams();\n const lineString = LineString3d.create([point1, point, point2, point1]);\n addGeometry(lineString, true);\n break;\n }\n\n case \"circle\": {\n const circle = Arc3d.createXY(point, radius);\n addGeometry(circle);\n break;\n }\n\n case \"circleFilled\": {\n addFillParams();\n const circle = Arc3d.createXY(point, radius);\n addGeometry(circle, true);\n break;\n }\n\n case \"slash\": {\n const normalizedVector = dir.normalize();\n if (!normalizedVector) throw new Error(\"Invalid reference vector for slash terminator.\");\n\n const rotatedVector = normalizedVector.rotateXY(Angle.createDegrees(45));\n const startPoint = point.plusScaled(rotatedVector, -radius);\n const endPoint = point.plusScaled(rotatedVector, radius);\n\n const slashLine = LineSegment3d.create(startPoint, endPoint);\n addGeometry(slashLine);\n break;\n }\n\n default:\n throw new Error(`Unknown terminator shape: ${textStyleSettings.leader.terminatorShape}`);\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,EAAmB,WAAW,EAAgG,MAAM,oBAAoB,CAAC;AAC1K,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAkB,aAAa,EAAE,YAAY,EAAE,IAAI,EAAQ,OAAO,EAAa,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACvJ,OAAO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G,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, FillDisplay, GeometryParams, TextAnnotationLeader, TextFrameStyleProps, TextStyleColor, TextStyleSettings } from \"@itwin/core-common\";\nimport { Angle, Arc3d, CurveCurve, CurvePrimitive, 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 const terminatorDirection = Vector3d.createStartEnd(\n leaderLinePoints[0], leaderLinePoints[1]\n ).normalize();\n const terminatorWidth = leaderStyle.leader.terminatorWidthFactor * scaledBlockTextHeight;\n // Truncate the first segment of the leader lines to account for the arrowhead size when closedArrow (hollow triangle) terminatorShape is used.\n if (leaderStyle.leader.terminatorShape === \"closedArrow\") {\n if (terminatorDirection)\n leaderLinePoints[0] = leaderLinePoints[0].plusScaled(terminatorDirection, terminatorWidth);\n }\n\n result = result && builder.appendGeometryQuery(LineString3d.create(leaderLinePoints));\n\n if (leaderStyle.leader.terminatorShape !== \"none\") {\n // Terminator geometry\n if (!terminatorDirection) continue; // Assuming leaders without terminators is a valid case.\n result = result && createTerminatorGeometry(builder, leader.startPoint, terminatorDirection, params, leaderStyle, scaledBlockTextHeight);\n\n }\n\n }\n return result;\n}\n\n/**\n * Creates the geometry for a terminator at the end of a leader line.\n * @param builder The geometry builder to append the terminator geometry to.\n * @param point The starting point of the leader line.\n * @param dir The direction vector of the leader line.\n * @param params The geometry parameters to use for the terminator.\n * @param textStyleSettings The text style settings to use for the terminator.\n * @param textHeight The height of the text block.\n * @returns True if the geometry was successfully created, false otherwise.\n * @beta\n */\nexport function createTerminatorGeometry(builder: ElementGeometry.Builder, point: Point3d, dir: Vector3d, params: GeometryParams, textStyleSettings: TextStyleSettings, textHeight: number): boolean {\n\n let result = true;\n const termY = dir.unitCrossProduct(Vector3d.unitZ());\n if (!termY) return false; // If dir is parallel to Z, we can't create a terminator\n const terminatorHeight = textStyleSettings.leader.terminatorHeightFactor * textHeight;\n const terminatorWidth = textStyleSettings.leader.terminatorWidthFactor * textHeight;\n const terminatorHalfHeight = terminatorHeight / 2;\n const basePoint = point.plusScaled(dir, terminatorWidth);\n const point1 = basePoint.plusScaled(termY, terminatorHalfHeight);\n const point2 = basePoint.plusScaled(termY.negate(), terminatorHalfHeight);\n\n // Helper function to add fill parameters\n const addFillParams = () => {\n params.fillDisplay = FillDisplay.Always;\n result = result && builder.appendGeometryParamsChange(params);\n };\n\n // Helper function to create geometry entry\n const addGeometry = (content: CurvePrimitive, useLoop = false) => {\n const finalContent = useLoop ? Loop.create(content) : content;\n result = result && builder.appendGeometryQuery(finalContent);\n };\n\n switch (textStyleSettings.leader.terminatorShape) {\n case \"openArrow\": {\n const lineString = LineString3d.create([point1, point, point2]);\n addGeometry(lineString);\n break;\n }\n\n case \"closedArrow\": {\n const lineString = LineString3d.create([point1, point, point2, point1]);\n addGeometry(lineString);\n break;\n }\n\n case \"closedArrowFilled\": {\n addFillParams();\n const lineString = LineString3d.create([point1, point, point2, point1]);\n addGeometry(lineString, true);\n break;\n }\n\n case \"circle\": {\n const circle = Arc3d.createXY(point, terminatorHalfHeight);\n addGeometry(circle);\n break;\n }\n\n case \"circleFilled\": {\n addFillParams();\n const circle = Arc3d.createXY(point, terminatorHalfHeight);\n addGeometry(circle, true);\n break;\n }\n\n case \"slash\": {\n const normalizedVector = dir.normalize();\n if (!normalizedVector) throw new Error(\"Invalid reference vector for slash terminator.\");\n\n const rotatedVector = normalizedVector.rotateXY(Angle.createDegrees(45));\n const startPoint = point.plusScaled(rotatedVector, -terminatorHalfHeight);\n const endPoint = point.plusScaled(rotatedVector, terminatorHalfHeight);\n\n const slashLine = LineSegment3d.create(startPoint, endPoint);\n addGeometry(slashLine);\n break;\n }\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextAnnotationElement.d.ts","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationElement.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,wBAAwB,EAAe,IAAI,EAAE,SAAS,EAAE,cAAc,EAA4E,kBAAkB,EAAe,gBAAgB,EAAe,gBAAgB,EAAkB,cAAc,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,sBAAsB,EAA8B,aAAa,EAAE,MAAM,oB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,mBAAmB;IAWvF;;;OAGG;IACa,MAAM,IAAI,wBAAwB;IAOlD,oFAAoF;WACtE,QAAQ,CAAC,KAAK,EAAE,wBAAwB,EAAE,MAAM,EAAE,QAAQ,GAAG,mBAAmB;IAI9F;;;;OAIG;qBACuB,QAAQ,CAAC,GAAG,EAAE,iBAAiB,GAAG,IAAI;IAKhE;;;;OAIG;qBACuB,QAAQ,CAAC,GAAG,EAAE,iBAAiB,GAAG,IAAI;IAKhE,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAU/B;;;;OAIG;IACH,0BAAmC,mBAAmB,EAAE,qBAAqB,EAAE,CAE7E;IAEF;;;;OAIG;WACoB,WAAW,CAAC,KAAK,EAAE,qBAAqB,GAAG,wBAAwB;IAS1F;;;;OAIG;WACoB,SAAS,CAAC,KAAK,EAAE,wBAAwB,EAAE,MAAM,EAAE,QAAQ,GAAG,QAAQ;IAQ7F,mGAAmG;IACnG,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAKrC;;;;;;OAMG;WACiB,gBAAgB,CAAC,iBAAiB,EAAE,UAAU,EAAE,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,UAAU,CAAC;qBA+B5F,QAAQ,CAAC,OAAO,EAAE,yBAAyB,EAAE,QAAQ,EAAE,wBAAwB,EAAE,QAAQ,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;CAkBpK"}
|
|
@@ -442,12 +442,11 @@ export const TEXT_STYLE_SETTINGS_JSON_VERSION = "1.0.1";
|
|
|
442
442
|
function migrateTextStyleSettings(oldData) {
|
|
443
443
|
if (oldData.version === TEXT_STYLE_SETTINGS_JSON_VERSION)
|
|
444
444
|
return oldData.data;
|
|
445
|
-
|
|
446
|
-
|
|
445
|
+
// Migrate from 1.0.0 to 1.0.1
|
|
446
|
+
if (oldData.data.leader && !oldData.data.leader.terminatorShape) {
|
|
447
|
+
oldData.data.leader.terminatorShape = TextStyleSettings.defaultProps.leader.terminatorShape;
|
|
447
448
|
}
|
|
448
449
|
return oldData.data;
|
|
449
|
-
// Only if something goes wrong, throw an error.
|
|
450
|
-
// throw new Error(`Migration for settings from version ${oldData.version} to ${TEXT_STYLE_SETTINGS_JSON_VERSION} failed.`);
|
|
451
450
|
}
|
|
452
451
|
/**
|
|
453
452
|
* The definition element that holds text style information.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextAnnotationElement.js","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationElement.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAA4B,WAAW,EAAE,IAAI,EAAwD,eAAe,EAAoD,WAAW,EAAoB,WAAW,EAAoC,cAAc,EAAqE,iBAAiB,EAA0B,0BAA0B,EAAiB,MAAM,oBAAoB,CAAC;AAEjc,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,OAAO,EAAE,kBAAkB,EAAqC,MAAM,YAAY,CAAC;AACpI,OAAO,EAAE,MAAM,EAAE,IAAI,EAAc,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,oCAAoC,EAAkB,MAAM,+BAA+B,CAAC;AAGlI,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC;;;EAGE;AACF,MAAM,CAAC,MAAM,4BAA4B,GAAG,OAAO,CAAC;AAEpD,SAAS,+BAA+B,CACtC,IAAY,EACZ,cAA+B,EAC/B,OAAqC;IAErC,IAAI,MAAM,CAAC;IACX,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAqB,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC/B,IAAI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,CAAC,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QACpE,OAAO,CAAC,YAAY,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;QACpD,OAAO,UAAU,CAAC;IACpB,CAAC;IAES,MAAM,CAAU,KAAK,CAAC,QAAQ,CAAC,OAAkC,EAAE,QAAkC,EAAE,QAAkC;QACjJ,MAAM,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAClD,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,MAAM,aAAa,GAAG,mBAAmB,CAAC,sBAAsB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACpF,MAAM,IAAI,GAAG,iBAAiB,CAAC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;QAElE,MAAM,YAAY,GAAG,EAAE,CAAC;QACxB,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,sBAAsB,EAAE,EAAE,CAAC;YACnE,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACxF,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QAED,MAAM,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACtG,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 Elements\n */\n\nimport { AnnotationTextStyleProps, BisCodeSpec, Code, CodeProps, CodeScopeProps, CodeSpec, ECVersionString, ElementGeometry, ElementGeometryBuilderParams, EntityReferenceSet, Placement2d, Placement2dProps, Placement3d, Placement3dProps, PlacementProps, TextAnnotation, TextAnnotation2dProps, TextAnnotation3dProps, TextAnnotationProps, TextStyleSettings, TextStyleSettingsProps, traverseTextBlockComponent, VersionedJSON } from \"@itwin/core-common\";\nimport { IModelDb } from \"../IModelDb\";\nimport { AnnotationElement2d, DefinitionElement, Drawing, GraphicalElement3d, OnElementIdArg, OnElementPropsArg } from \"../Element\";\nimport { assert, Id64, Id64String } from \"@itwin/core-bentley\";\nimport { layoutTextBlock, TextStyleResolver } from \"./TextBlockLayout\";\nimport { appendTextAnnotationGeometry } from \"./TextAnnotationGeometry\";\nimport { ElementDrivesTextAnnotation, TextAnnotationUsesTextStyleByDefault, TextBlockAndId } from \"./ElementDrivesTextAnnotation\";\nimport { IModelElementCloneContext } from \"../IModelElementCloneContext\";\nimport { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow } from \"../Entity\";\nimport * as semver from \"semver\";\n\n/** The version of the JSON stored in `TextAnnotation2d/3dProps.textAnnotationData` used by the code.\n * Uses the same semantics as [ECVersion]($ecschema-metadata).\n * @internal\n*/\nexport const TEXT_ANNOTATION_JSON_VERSION = \"1.0.0\";\n\nfunction validateAndMigrateVersionedJSON<T>(\n json: string,\n currentVersion: ECVersionString,\n migrate: (old: VersionedJSON<T>) => T\n): VersionedJSON<T> | undefined {\n let parsed;\n try {\n parsed = JSON.parse(json) as VersionedJSON<T>;\n } catch {\n return undefined;\n }\n\n const version = parsed.version;\n if (typeof version !== \"string\" || !semver.valid(version))\n throw new Error(\"JSON version is missing or invalid.\");\n\n if (typeof parsed.data !== \"object\" || parsed.data === null)\n throw new Error(\"JSON data is missing or invalid.\");\n\n // Newer\n if (semver.gt(version, currentVersion))\n throw new Error(`JSON version ${parsed.version} is newer than supported version ${currentVersion}. Application update required to understand data.`);\n\n // Older\n if (semver.lt(version, currentVersion)) {\n parsed.data = migrate(parsed);\n parsed.version = currentVersion;\n }\n\n return parsed;\n}\n\nfunction migrateTextAnnotationData(oldData: VersionedJSON<TextAnnotationProps>): TextAnnotationProps {\n if (oldData.version === TEXT_ANNOTATION_JSON_VERSION) return oldData.data;\n\n // Place migration logic here.\n\n throw new Error(`Migration for textAnnotationData from version ${oldData.version} to ${TEXT_ANNOTATION_JSON_VERSION} failed.`);\n}\n\n/** Parses, validates, and potentially migrates the text annotation data from a JSON string.\n * @internal\n */\nexport function parseTextAnnotationData(json: string | undefined): VersionedJSON<TextAnnotationProps> | undefined {\n if (!json) return undefined;\n\n return validateAndMigrateVersionedJSON<TextAnnotationProps>(json, TEXT_ANNOTATION_JSON_VERSION, migrateTextAnnotationData);\n}\n\nfunction getElementGeometryBuilderParams(iModel: IModelDb, modelId: Id64String, categoryId: Id64String, _placementProps: PlacementProps, annotationProps?: TextAnnotationProps, textStyleId?: Id64String, _subCategory?: Id64String): ElementGeometryBuilderParams {\n const textBlock = TextAnnotation.fromJSON(annotationProps).textBlock;\n const textStyleResolver = new TextStyleResolver({ textBlock, textStyleId: textStyleId ?? \"\", iModel });\n const layout = layoutTextBlock({ iModel, textBlock, textStyleResolver });\n const builder = new ElementGeometry.Builder();\n let scaleFactor = 1;\n const element = iModel.elements.getElement(modelId);\n if (element instanceof Drawing)\n scaleFactor = element.scaleFactor;\n appendTextAnnotationGeometry({ layout, textStyleResolver, scaleFactor, annotationProps: annotationProps ?? {}, builder, categoryId });\n\n return { entryArray: builder.entries };\n}\n\n/** Arguments supplied when creating a [[TextAnnotation2d]].\n * @beta\n */\nexport interface TextAnnotation2dCreateArgs {\n /** The category ID for the annotation. */\n category: Id64String;\n /** The model ID where the annotation will be placed. */\n model: Id64String;\n /** The placement properties for the annotation. */\n placement: Placement2dProps;\n /** The default text style ID for the annotation. */\n defaultTextStyleId?: Id64String;\n /** Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation2d`. Essentially an empty element if not provided. */\n textAnnotationProps?: TextAnnotationProps;\n /** Optional code for the element. */\n code?: CodeProps;\n}\n\n/** Arguments supplied when creating a [[TextAnnotation3d]].\n * @beta\n */\nexport interface TextAnnotation3dCreateArgs {\n /** The category ID for the annotation. */\n category: Id64String;\n /** The model ID where the annotation will be placed. */\n model: Id64String;\n /** The placement properties for the annotation. */\n placement: Placement3dProps;\n /** The default text style ID for the annotation. */\n defaultTextStyleId?: Id64String;\n /** Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation3d`. Essentially an empty element if not provided. */\n textAnnotationProps?: TextAnnotationProps;\n /** Optional code for the element. */\n code?: CodeProps;\n}\n\n/** An element that displays textual content within a 2d model.\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\n * @see [[setAnnotation]] to change the textual content.\n * @public @preview\n */\nexport class TextAnnotation2d extends AnnotationElement2d /* implements ITextAnnotation */ {\n /** @internal */\n public static override get className(): string { return \"TextAnnotation2d\"; }\n /**\n * The default [[AnnotationTextStyle]] used by the TextAnnotation2d.\n * @beta\n */\n public defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\n /** The data associated with the text annotation. */\n private _textAnnotationProps?: TextAnnotationProps;\n\n /** Extract the textual content, if present.\n * @see [[setAnnotation]] to change it.\n */\n public getAnnotation(): TextAnnotation | undefined {\n return this._textAnnotationProps ? TextAnnotation.fromJSON(this._textAnnotationProps) : undefined;\n }\n\n /** Change the textual content of the `TextAnnotation2d`.\n * @see [[getAnnotation]] to extract the current annotation.\n * @param annotation The new annotation\n */\n public setAnnotation(annotation: TextAnnotation) {\n this._textAnnotationProps = annotation.toJSON();\n }\n\n protected constructor(props: TextAnnotation2dProps, iModel: IModelDb) {\n super(props, iModel);\n if (props.defaultTextStyle) {\n this.defaultTextStyle = new TextAnnotationUsesTextStyleByDefault(props.defaultTextStyle.id);\n }\n this._textAnnotationProps = parseTextAnnotationData(props.textAnnotationData)?.data;\n }\n\n /** Creates a new instance of `TextAnnotation2d` from its JSON representation. */\n public static fromJSON(props: TextAnnotation2dProps, iModel: IModelDb): TextAnnotation2d {\n return new TextAnnotation2d(props, iModel);\n }\n\n /**\n * Converts the current `TextAnnotation2d` instance to its JSON representation.\n * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.\n * @inheritdoc\n */\n public override toJSON(): TextAnnotation2dProps {\n const props = super.toJSON() as TextAnnotation2dProps;\n props.textAnnotationData = this._textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: this._textAnnotationProps }) : undefined;\n if (this._textAnnotationProps) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.category, this.placement, this._textAnnotationProps, this.defaultTextStyle ? this.defaultTextStyle.id : undefined);\n }\n\n return props;\n }\n\n /** Creates a new `TextAnnotation2d` instance with the specified properties.\n * @param iModelDb The iModel.\n * @param arg The arguments for creating the TextAnnotation2d.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextAnnotation2dCreateArgs): TextAnnotation2d {\n const elementProps: TextAnnotation2dProps = {\n classFullName: this.classFullName,\n textAnnotationData: arg.textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: arg.textAnnotationProps }) : undefined,\n defaultTextStyle: arg.defaultTextStyleId ? new TextAnnotationUsesTextStyleByDefault(arg.defaultTextStyleId).toJSON() : undefined,\n placement: arg.placement,\n model: arg.model,\n category: arg.category,\n code: arg.code ?? Code.createEmpty(),\n };\n return new this(elementProps, iModelDb);\n }\n\n /**\n * Updates the geometry of the TextAnnotation2d on insert and validates version.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Updates the geometry of the TextAnnotation2d on update and validates version.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation2dProps]($common).\n * Only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.\n * Also, validates the version of the text annotation data and migrates it if necessary.\n * @beta\n */\n protected static validateVersionAndUpdateGeometry(arg: OnElementPropsArg): void {\n const props = arg.props as TextAnnotation2dProps;\n const textAnnotationData = parseTextAnnotationData(props.textAnnotationData);\n if (!props.elementGeometryBuilderParams && textAnnotationData) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(arg.iModel, props.model, props.category, props.placement ?? Placement2d.fromJSON(), textAnnotationData.data, props.defaultTextStyle?.id);\n }\n }\n\n /**\n * TextAnnotation2d custom HandledProps include 'textAnnotationData'.\n * @inheritdoc\n * @internal\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"textAnnotationData\", source: \"Class\" },\n ];\n\n /**\n * TextAnnotation2d deserializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): TextAnnotation2dProps {\n const elProps = super.deserialize(props) as TextAnnotation2dProps;\n const textAnnotationData = parseTextAnnotationData(props.row.textAnnotationData);\n if (textAnnotationData) {\n elProps.textAnnotationData = JSON.stringify(textAnnotationData);\n }\n return elProps;\n }\n\n /**\n * TextAnnotation2d serializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: TextAnnotation2dProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.textAnnotationData !== undefined) {\n inst.textAnnotationData = props.textAnnotationData;\n }\n return inst;\n }\n\n /** @internal */\n public getTextBlocks(): Iterable<TextBlockAndId> {\n return getTextBlocks(this);\n }\n\n /** @internal */\n public updateTextBlocks(textBlocks: TextBlockAndId[]): void {\n return updateTextBlocks(this, textBlocks);\n }\n\n /** @internal */\n public static override onInserted(arg: OnElementIdArg): void {\n super.onInserted(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n /** @internal */\n public static override onUpdated(arg: OnElementIdArg): void {\n super.onUpdated(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n collectReferenceIds(this, referenceIds);\n }\n\n /** @internal */\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: TextAnnotation2dProps, dstProps: TextAnnotation2dProps): Promise<void> {\n await super.onCloned(context, srcProps, dstProps);\n\n const srcElem = TextAnnotation2d.fromJSON(srcProps, context.sourceDb);\n ElementDrivesTextAnnotation.remapFields(srcElem, context);\n const anno = srcElem.getAnnotation();\n dstProps.textAnnotationData = anno ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: anno.toJSON() }) : undefined;\n\n return remapTextStyle(context, srcElem, dstProps);\n }\n}\n\n/** An element that displays textual content within a 3d model.\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\n * @see [[setAnnotation]] to change the textual content.\n * @public @preview\n */\nexport class TextAnnotation3d extends GraphicalElement3d /* implements ITextAnnotation */ {\n /** @internal */\n public static override get className(): string { return \"TextAnnotation3d\"; }\n /**\n * The default [[AnnotationTextStyle]] used by the TextAnnotation3d.\n * @beta\n */\n public defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\n /** The data associated with the text annotation. */\n private _textAnnotationProps?: TextAnnotationProps;\n\n /** Extract the textual content, if present.\n * @see [[setAnnotation]] to change it.\n */\n public getAnnotation(): TextAnnotation | undefined {\n return this._textAnnotationProps ? TextAnnotation.fromJSON(this._textAnnotationProps) : undefined;\n }\n\n /** Change the textual content of the `TextAnnotation3d`.\n * @see [[getAnnotation]] to extract the current annotation.\n * @param annotation The new annotation\n */\n public setAnnotation(annotation: TextAnnotation) {\n this._textAnnotationProps = annotation.toJSON();\n }\n\n protected constructor(props: TextAnnotation3dProps, iModel: IModelDb) {\n super(props, iModel);\n if (props.defaultTextStyle) {\n this.defaultTextStyle = new TextAnnotationUsesTextStyleByDefault(props.defaultTextStyle.id);\n }\n this._textAnnotationProps = parseTextAnnotationData(props.textAnnotationData)?.data;\n }\n\n /** Creates a new instance of `TextAnnotation3d` from its JSON representation. */\n public static fromJSON(props: TextAnnotation3dProps, iModel: IModelDb): TextAnnotation3d {\n return new TextAnnotation3d(props, iModel);\n }\n\n /**\n * Converts the current `TextAnnotation3d` instance to its JSON representation.\n * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.\n * @inheritdoc\n */\n public override toJSON(): TextAnnotation3dProps {\n const props = super.toJSON() as TextAnnotation3dProps;\n props.textAnnotationData = this._textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: this._textAnnotationProps }) : undefined;\n if (this._textAnnotationProps) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.category, this.placement, this._textAnnotationProps, this.defaultTextStyle ? this.defaultTextStyle.id : undefined);\n }\n\n return props;\n }\n\n /** Creates a new `TextAnnotation3d` instance with the specified properties.\n * @param iModelDb The iModel.\n * @param arg The arguments for creating the TextAnnotation3d.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextAnnotation3dCreateArgs): TextAnnotation3d {\n const elementProps: TextAnnotation3dProps = {\n classFullName: this.classFullName,\n textAnnotationData: arg.textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: arg.textAnnotationProps }) : undefined,\n defaultTextStyle: arg.defaultTextStyleId ? new TextAnnotationUsesTextStyleByDefault(arg.defaultTextStyleId).toJSON() : undefined,\n placement: arg.placement,\n model: arg.model,\n category: arg.category,\n code: arg.code ?? Code.createEmpty(),\n };\n return new this(elementProps, iModelDb);\n }\n\n /**\n * Updates the geometry of the TextAnnotation3d on insert and validates version..\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Updates the geometry of the TextAnnotation3d on update and validates version..\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation3dProps]($common).\n * Only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.\n * Also, validates the version of the text annotation data and migrates it if necessary.\n * @beta\n */\n protected static validateVersionAndUpdateGeometry(arg: OnElementPropsArg): void {\n const props = arg.props as TextAnnotation3dProps;\n const textAnnotationData = parseTextAnnotationData(props.textAnnotationData);\n if (!props.elementGeometryBuilderParams && textAnnotationData) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(arg.iModel, props.model, props.category, props.placement ?? Placement3d.fromJSON(), textAnnotationData.data, props.defaultTextStyle?.id);\n }\n }\n\n /**\n * TextAnnotation3d custom HandledProps include 'textAnnotationData'.\n * @inheritdoc\n * @internal\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"textAnnotationData\", source: \"Class\" },\n ];\n\n /**\n * TextAnnotation3d deserializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): TextAnnotation3dProps {\n const elProps = super.deserialize(props) as TextAnnotation3dProps;\n const textAnnotationData = parseTextAnnotationData(props.row.textAnnotationData);\n if (textAnnotationData) {\n elProps.textAnnotationData = JSON.stringify(textAnnotationData);\n }\n return elProps;\n }\n\n /**\n * TextAnnotation3d serializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: TextAnnotation3dProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.textAnnotationData !== undefined) {\n inst.textAnnotationData = props.textAnnotationData;\n }\n return inst;\n }\n\n /** @internal */\n public getTextBlocks(): Iterable<TextBlockAndId> {\n return getTextBlocks(this);\n }\n\n /** @internal */\n public updateTextBlocks(textBlocks: TextBlockAndId[]): void {\n return updateTextBlocks(this, textBlocks);\n }\n\n /** @internal */\n public static override onInserted(arg: OnElementIdArg): void {\n super.onInserted(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n /** @internal */\n public static override onUpdated(arg: OnElementIdArg): void {\n super.onUpdated(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n collectReferenceIds(this, referenceIds);\n }\n\n /** @internal */\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: TextAnnotation3dProps, dstProps: TextAnnotation3dProps): Promise<void> {\n await super.onCloned(context, srcProps, dstProps);\n\n const srcElem = TextAnnotation3d.fromJSON(srcProps, context.sourceDb);\n ElementDrivesTextAnnotation.remapFields(srcElem, context);\n const anno = srcElem.getAnnotation();\n dstProps.textAnnotationData = anno ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: anno.toJSON() }) : undefined;\n\n return remapTextStyle(context, srcElem, dstProps);\n }\n}\n\nasync function remapTextStyle(\n context: IModelElementCloneContext,\n srcElem: TextAnnotation2d | TextAnnotation3d,\n dstProps: TextAnnotation2dProps | TextAnnotation3dProps\n): Promise<void> {\n const dstStyleId = await AnnotationTextStyle.remapTextStyleId(srcElem.defaultTextStyle?.id ?? Id64.invalid, context);\n dstProps.defaultTextStyle = Id64.isValid(dstStyleId) ? new TextAnnotationUsesTextStyleByDefault(dstStyleId).toJSON() : undefined;\n}\n\nfunction collectReferenceIds(elem: TextAnnotation2d | TextAnnotation3d, referenceIds: EntityReferenceSet): void {\n const style = elem.defaultTextStyle?.id;\n if (style && Id64.isValidId64(style)) {\n referenceIds.addElement(style);\n }\n\n const block = elem.getAnnotation()?.textBlock;\n if (block) {\n for (const { child } of traverseTextBlockComponent(block)) {\n if (child.type === \"field\") {\n const hostId = child.propertyHost.elementId;\n if (Id64.isValidId64(hostId)) {\n referenceIds.addElement(hostId);\n }\n }\n }\n }\n}\n\nfunction getTextBlocks(elem: TextAnnotation2d | TextAnnotation3d): Iterable<TextBlockAndId> {\n const annotation = elem.getAnnotation();\n return annotation ? [{ textBlock: annotation.textBlock, id: undefined }] : [];\n}\n\nfunction updateTextBlocks(elem: TextAnnotation2d | TextAnnotation3d, textBlocks: TextBlockAndId[]): void {\n assert(textBlocks.length === 1);\n assert(textBlocks[0].id === undefined);\n\n const annotation = elem.getAnnotation();\n if (!annotation) {\n // We must obtain the TextBlockAndId from the element in the first place, so the only way we could end up here is if\n // somebody removed the text annotation after we called getTextBlocks. That's gotta be a mistake.\n throw new Error(\"Text annotation element has no text\");\n }\n\n annotation.textBlock = textBlocks[0].textBlock;\n\n elem.setAnnotation(annotation);\n}\n\n/** The version of the JSON stored in `AnnotationTextStyleProps.settings` used by the code.\n * Uses the same semantics as [ECVersion]($ecschema-metadata).\n * @internal\n*/\n// 1.0.1 - Added terminatorShapes for leaders\nexport const TEXT_STYLE_SETTINGS_JSON_VERSION = \"1.0.1\";\n\nfunction migrateTextStyleSettings(oldData: VersionedJSON<TextStyleSettingsProps>): TextStyleSettingsProps {\n if (oldData.version === TEXT_STYLE_SETTINGS_JSON_VERSION) return oldData.data;\n\n if (oldData.data.leader) {\n oldData.data.leader.terminatorShape = oldData.data.leader.terminatorShape ?? TextStyleSettings.defaultProps.leader.terminatorShape;\n }\n return oldData.data;\n\n // Only if something goes wrong, throw an error.\n // throw new Error(`Migration for settings from version ${oldData.version} to ${TEXT_STYLE_SETTINGS_JSON_VERSION} failed.`);\n}\n\n/** Arguments supplied when creating an [[AnnotationTextStyle]].\n * @beta\n */\nexport interface TextStyleCreateArgs {\n /** The ID of the [[DefinitionModel]]. */\n definitionModelId: Id64String;\n /** The name to assign to the [[AnnotationTextStyle]]. */\n name: string;\n /** Optional text style settings used to create the [[AnnotationTextStyle]]. Default settings will be used if not provided. */\n settings?: TextStyleSettingsProps;\n /** Optional description for the [[AnnotationTextStyle]]. */\n description?: string;\n}\n\n/**\n * The definition element that holds text style information.\n * The style is stored as a [TextStyleSettings]($common).\n * @beta\n */\nexport class AnnotationTextStyle extends DefinitionElement {\n /** @internal */\n public static override get className(): string { return \"AnnotationTextStyle\"; }\n /**\n * Optional text describing the `AnnotationTextStyle`.\n */\n public description?: string;\n /**\n * The text style settings for the `AnnotationTextStyle`.\n * @see [[TextStyleSettings]] for more information.\n */\n public settings: TextStyleSettings;\n\n protected constructor(props: AnnotationTextStyleProps, iModel: IModelDb) {\n super(props, iModel);\n this.description = props.description;\n const settingsProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);\n this.settings = TextStyleSettings.fromJSON(settingsProps?.data);\n }\n\n /**\n * Creates a Code for an `AnnotationTextStyle` given a name that is meant to be unique within the scope of the specified DefinitionModel.\n *\n * @param iModel - The IModelDb.\n * @param definitionModelId - The ID of the DefinitionModel that contains the AnnotationTextStyle and provides the scope for its name.\n * @param name - The AnnotationTextStyle name.\n * @beta\n */\n public static createCode(iModel: IModelDb, definitionModelId: CodeScopeProps, name: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.annotationTextStyle);\n return new Code({ spec: codeSpec.id, scope: definitionModelId, value: name });\n }\n\n /**\n * Creates a new instance of `AnnotationTextStyle` with the specified properties.\n *\n * @param iModelDb - The iModelDb.\n * @param arg - The arguments for creating the AnnotationTextStyle.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextStyleCreateArgs): AnnotationTextStyle {\n const props: AnnotationTextStyleProps = {\n classFullName: this.classFullName,\n model: arg.definitionModelId,\n code: this.createCode(iModelDb, arg.definitionModelId, arg.name).toJSON(),\n description: arg.description,\n settings: arg.settings ? JSON.stringify({ version: TEXT_STYLE_SETTINGS_JSON_VERSION, data: arg.settings }) : undefined,\n }\n return new this(props, iModelDb);\n }\n\n /**\n * Converts the current `AnnotationTextStyle` instance to its JSON representation.\n * @inheritdoc\n */\n public override toJSON(): AnnotationTextStyleProps {\n const props = super.toJSON() as AnnotationTextStyleProps;\n props.description = this.description;\n props.settings = JSON.stringify({ version: TEXT_STYLE_SETTINGS_JSON_VERSION, data: this.settings.toJSON() });\n return props;\n }\n\n /** Creates a new instance of `AnnotationTextStyle` from its JSON representation. */\n public static fromJSON(props: AnnotationTextStyleProps, iModel: IModelDb): AnnotationTextStyle {\n return new AnnotationTextStyle(props, iModel);\n }\n\n /**\n * Validates that the AnnotationTextStyle's settings are valid before insert.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateSettings(arg.props as AnnotationTextStyleProps);\n }\n\n /**\n * Validates that the AnnotationTextStyle's settings are valid before update.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateSettings(arg.props as AnnotationTextStyleProps);\n }\n\n private static validateSettings(props: AnnotationTextStyleProps): void {\n const settingProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);\n if (!settingProps) return;\n const settings = TextStyleSettings.fromJSON(settingProps.data);\n const errors = settings.getValidationErrors();\n if (errors.length > 0) {\n throw new Error(`Invalid AnnotationTextStyle settings: ${errors.join(\", \")}`);\n }\n }\n\n /**\n * AnnotationTextStyle custom HandledProps include 'settings'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"settings\", source: \"Class\" },\n ];\n\n /**\n * AnnotationTextStyle deserializes 'settings'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): AnnotationTextStyleProps {\n const elProps = super.deserialize(props) as AnnotationTextStyleProps;\n const settings = this.parseTextStyleSettings(props.row.settings);\n if (settings) {\n elProps.settings = JSON.stringify(settings);\n }\n return elProps;\n }\n\n /**\n * AnnotationTextStyle serializes 'settings'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: AnnotationTextStyleProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.settings !== undefined) {\n inst.settings = props.settings;\n }\n return inst;\n }\n\n /** Parses, validates, and potentially migrates the text style settings data from a JSON string. */\n private static parseTextStyleSettings(json: string | undefined): VersionedJSON<TextStyleSettingsProps> | undefined {\n if (!json) return undefined;\n return validateAndMigrateVersionedJSON<TextStyleSettingsProps>(json, TEXT_STYLE_SETTINGS_JSON_VERSION, migrateTextStyleSettings);\n }\n\n /** When copying an element from one iModel to another, returns the Id of the AnnotationTextStyle in the `context`'s target iModel\n * corresponding to `sourceTextStyleId`, or [Id64.invalid]($bentley) if no corresponding text style exists.\n * If a text style with the same [Code]($common) exists in the target iModel, the style Id will be remapped to refer to that style.\n * Otherwise, a copy of the style will be imported into the target iModel and its element Id returned.\n * Implementations of [[ITextAnnotation]] should invoke this function when implementing their [[Element.onCloned]] method.\n * @throws Error if an attempt to import the text style failed.\n */\n public static async remapTextStyleId(sourceTextStyleId: Id64String, context: IModelElementCloneContext): Promise<Id64String> {\n // No remapping necessary if there's no text style or we're not copying to a different iModel.\n if (!Id64.isValid(sourceTextStyleId) || !context.isBetweenIModels) {\n return sourceTextStyleId;\n }\n\n // If the style's already been remapped, we're finished.\n let dstStyleId: Id64String | undefined = context.findTargetElementId(sourceTextStyleId);\n if (Id64.isValid(dstStyleId)) {\n return dstStyleId;\n }\n\n // Look up the style. It really ought to exist.\n const srcStyle = context.sourceDb.elements.tryGetElement<AnnotationTextStyle>(sourceTextStyleId);\n if (!srcStyle) {\n return Id64.invalid;\n }\n\n // If a style with the same code exists in the target iModel, remap to that one.\n dstStyleId = context.targetDb.elements.queryElementIdByCode(srcStyle.code);\n if (undefined !== dstStyleId) {\n return dstStyleId;\n }\n\n // Copy the style into the target iModel and remap its Id.\n const dstStyleProps = await context.cloneElement(srcStyle);\n dstStyleId = context.targetDb.elements.insertElement(dstStyleProps);\n context.remapElement(sourceTextStyleId, dstStyleId);\n return dstStyleId;\n }\n\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: AnnotationTextStyleProps, dstProps: AnnotationTextStyleProps): Promise<void> {\n await super.onCloned(context, srcProps, dstProps);\n if (!context.isBetweenIModels) {\n return;\n }\n\n const settingsProps = AnnotationTextStyle.parseTextStyleSettings(srcProps.settings);\n const font = TextStyleSettings.fromJSON(settingsProps?.data).font;\n\n const fontsToEmbed = [];\n for (const file of context.sourceDb.fonts.queryEmbeddedFontFiles()) {\n if (file.type === font.type && file.faces.some((face) => face.familyName === font.name)) {\n fontsToEmbed.push(file);\n }\n }\n\n await Promise.all(fontsToEmbed.map(async (file) => context.targetDb.fonts.embedFontFile({ file })));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TextAnnotationElement.js","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationElement.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAA4B,WAAW,EAAE,IAAI,EAAwD,eAAe,EAAoD,WAAW,EAAoB,WAAW,EAAoC,cAAc,EAAqE,iBAAiB,EAA0B,0BAA0B,EAAiB,MAAM,oBAAoB,CAAC;AAEjc,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,OAAO,EAAE,kBAAkB,EAAqC,MAAM,YAAY,CAAC;AACpI,OAAO,EAAE,MAAM,EAAE,IAAI,EAAc,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,oCAAoC,EAAkB,MAAM,+BAA+B,CAAC;AAGlI,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC;;;EAGE;AACF,MAAM,CAAC,MAAM,4BAA4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,CAAC;QACH,CAAC;QAED,MAAM,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACtG,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 Elements\n */\n\nimport { AnnotationTextStyleProps, BisCodeSpec, Code, CodeProps, CodeScopeProps, CodeSpec, ECVersionString, ElementGeometry, ElementGeometryBuilderParams, EntityReferenceSet, Placement2d, Placement2dProps, Placement3d, Placement3dProps, PlacementProps, TextAnnotation, TextAnnotation2dProps, TextAnnotation3dProps, TextAnnotationProps, TextStyleSettings, TextStyleSettingsProps, traverseTextBlockComponent, VersionedJSON } from \"@itwin/core-common\";\nimport { IModelDb } from \"../IModelDb\";\nimport { AnnotationElement2d, DefinitionElement, Drawing, GraphicalElement3d, OnElementIdArg, OnElementPropsArg } from \"../Element\";\nimport { assert, Id64, Id64String } from \"@itwin/core-bentley\";\nimport { layoutTextBlock, TextStyleResolver } from \"./TextBlockLayout\";\nimport { appendTextAnnotationGeometry } from \"./TextAnnotationGeometry\";\nimport { ElementDrivesTextAnnotation, TextAnnotationUsesTextStyleByDefault, TextBlockAndId } from \"./ElementDrivesTextAnnotation\";\nimport { IModelElementCloneContext } from \"../IModelElementCloneContext\";\nimport { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow } from \"../Entity\";\nimport * as semver from \"semver\";\n\n/** The version of the JSON stored in `TextAnnotation2d/3dProps.textAnnotationData` used by the code.\n * Uses the same semantics as [ECVersion]($ecschema-metadata).\n * @internal\n*/\nexport const TEXT_ANNOTATION_JSON_VERSION = \"1.0.0\";\n\nfunction validateAndMigrateVersionedJSON<T>(\n json: string,\n currentVersion: ECVersionString,\n migrate: (old: VersionedJSON<T>) => T\n): VersionedJSON<T> | undefined {\n let parsed;\n try {\n parsed = JSON.parse(json) as VersionedJSON<T>;\n } catch {\n return undefined;\n }\n\n const version = parsed.version;\n if (typeof version !== \"string\" || !semver.valid(version))\n throw new Error(\"JSON version is missing or invalid.\");\n\n if (typeof parsed.data !== \"object\" || parsed.data === null)\n throw new Error(\"JSON data is missing or invalid.\");\n\n // Newer\n if (semver.gt(version, currentVersion))\n throw new Error(`JSON version ${parsed.version} is newer than supported version ${currentVersion}. Application update required to understand data.`);\n\n // Older\n if (semver.lt(version, currentVersion)) {\n parsed.data = migrate(parsed);\n parsed.version = currentVersion;\n }\n\n return parsed;\n}\n\nfunction migrateTextAnnotationData(oldData: VersionedJSON<TextAnnotationProps>): TextAnnotationProps {\n if (oldData.version === TEXT_ANNOTATION_JSON_VERSION) return oldData.data;\n\n // Place migration logic here.\n\n throw new Error(`Migration for textAnnotationData from version ${oldData.version} to ${TEXT_ANNOTATION_JSON_VERSION} failed.`);\n}\n\n/** Parses, validates, and potentially migrates the text annotation data from a JSON string.\n * @internal\n */\nexport function parseTextAnnotationData(json: string | undefined): VersionedJSON<TextAnnotationProps> | undefined {\n if (!json) return undefined;\n\n return validateAndMigrateVersionedJSON<TextAnnotationProps>(json, TEXT_ANNOTATION_JSON_VERSION, migrateTextAnnotationData);\n}\n\nfunction getElementGeometryBuilderParams(iModel: IModelDb, modelId: Id64String, categoryId: Id64String, _placementProps: PlacementProps, annotationProps?: TextAnnotationProps, textStyleId?: Id64String, _subCategory?: Id64String): ElementGeometryBuilderParams {\n const textBlock = TextAnnotation.fromJSON(annotationProps).textBlock;\n const textStyleResolver = new TextStyleResolver({ textBlock, textStyleId: textStyleId ?? \"\", iModel });\n const layout = layoutTextBlock({ iModel, textBlock, textStyleResolver });\n const builder = new ElementGeometry.Builder();\n let scaleFactor = 1;\n const element = iModel.elements.getElement(modelId);\n if (element instanceof Drawing)\n scaleFactor = element.scaleFactor;\n appendTextAnnotationGeometry({ layout, textStyleResolver, scaleFactor, annotationProps: annotationProps ?? {}, builder, categoryId });\n\n return { entryArray: builder.entries };\n}\n\n/** Arguments supplied when creating a [[TextAnnotation2d]].\n * @beta\n */\nexport interface TextAnnotation2dCreateArgs {\n /** The category ID for the annotation. */\n category: Id64String;\n /** The model ID where the annotation will be placed. */\n model: Id64String;\n /** The placement properties for the annotation. */\n placement: Placement2dProps;\n /** The default text style ID for the annotation. */\n defaultTextStyleId?: Id64String;\n /** Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation2d`. Essentially an empty element if not provided. */\n textAnnotationProps?: TextAnnotationProps;\n /** Optional code for the element. */\n code?: CodeProps;\n}\n\n/** Arguments supplied when creating a [[TextAnnotation3d]].\n * @beta\n */\nexport interface TextAnnotation3dCreateArgs {\n /** The category ID for the annotation. */\n category: Id64String;\n /** The model ID where the annotation will be placed. */\n model: Id64String;\n /** The placement properties for the annotation. */\n placement: Placement3dProps;\n /** The default text style ID for the annotation. */\n defaultTextStyleId?: Id64String;\n /** Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation3d`. Essentially an empty element if not provided. */\n textAnnotationProps?: TextAnnotationProps;\n /** Optional code for the element. */\n code?: CodeProps;\n}\n\n/** An element that displays textual content within a 2d model.\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\n * @see [[setAnnotation]] to change the textual content.\n * @public @preview\n */\nexport class TextAnnotation2d extends AnnotationElement2d /* implements ITextAnnotation */ {\n /** @internal */\n public static override get className(): string { return \"TextAnnotation2d\"; }\n /**\n * The default [[AnnotationTextStyle]] used by the TextAnnotation2d.\n * @beta\n */\n public defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\n /** The data associated with the text annotation. */\n private _textAnnotationProps?: TextAnnotationProps;\n\n /** Extract the textual content, if present.\n * @see [[setAnnotation]] to change it.\n */\n public getAnnotation(): TextAnnotation | undefined {\n return this._textAnnotationProps ? TextAnnotation.fromJSON(this._textAnnotationProps) : undefined;\n }\n\n /** Change the textual content of the `TextAnnotation2d`.\n * @see [[getAnnotation]] to extract the current annotation.\n * @param annotation The new annotation\n */\n public setAnnotation(annotation: TextAnnotation) {\n this._textAnnotationProps = annotation.toJSON();\n }\n\n protected constructor(props: TextAnnotation2dProps, iModel: IModelDb) {\n super(props, iModel);\n if (props.defaultTextStyle) {\n this.defaultTextStyle = new TextAnnotationUsesTextStyleByDefault(props.defaultTextStyle.id);\n }\n this._textAnnotationProps = parseTextAnnotationData(props.textAnnotationData)?.data;\n }\n\n /** Creates a new instance of `TextAnnotation2d` from its JSON representation. */\n public static fromJSON(props: TextAnnotation2dProps, iModel: IModelDb): TextAnnotation2d {\n return new TextAnnotation2d(props, iModel);\n }\n\n /**\n * Converts the current `TextAnnotation2d` instance to its JSON representation.\n * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.\n * @inheritdoc\n */\n public override toJSON(): TextAnnotation2dProps {\n const props = super.toJSON() as TextAnnotation2dProps;\n props.textAnnotationData = this._textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: this._textAnnotationProps }) : undefined;\n if (this._textAnnotationProps) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.category, this.placement, this._textAnnotationProps, this.defaultTextStyle ? this.defaultTextStyle.id : undefined);\n }\n\n return props;\n }\n\n /** Creates a new `TextAnnotation2d` instance with the specified properties.\n * @param iModelDb The iModel.\n * @param arg The arguments for creating the TextAnnotation2d.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextAnnotation2dCreateArgs): TextAnnotation2d {\n const elementProps: TextAnnotation2dProps = {\n classFullName: this.classFullName,\n textAnnotationData: arg.textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: arg.textAnnotationProps }) : undefined,\n defaultTextStyle: arg.defaultTextStyleId ? new TextAnnotationUsesTextStyleByDefault(arg.defaultTextStyleId).toJSON() : undefined,\n placement: arg.placement,\n model: arg.model,\n category: arg.category,\n code: arg.code ?? Code.createEmpty(),\n };\n return new this(elementProps, iModelDb);\n }\n\n /**\n * Updates the geometry of the TextAnnotation2d on insert and validates version.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Updates the geometry of the TextAnnotation2d on update and validates version.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation2dProps]($common).\n * Only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.\n * Also, validates the version of the text annotation data and migrates it if necessary.\n * @beta\n */\n protected static validateVersionAndUpdateGeometry(arg: OnElementPropsArg): void {\n const props = arg.props as TextAnnotation2dProps;\n const textAnnotationData = parseTextAnnotationData(props.textAnnotationData);\n if (!props.elementGeometryBuilderParams && textAnnotationData) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(arg.iModel, props.model, props.category, props.placement ?? Placement2d.fromJSON(), textAnnotationData.data, props.defaultTextStyle?.id);\n }\n }\n\n /**\n * TextAnnotation2d custom HandledProps include 'textAnnotationData'.\n * @inheritdoc\n * @internal\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"textAnnotationData\", source: \"Class\" },\n ];\n\n /**\n * TextAnnotation2d deserializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): TextAnnotation2dProps {\n const elProps = super.deserialize(props) as TextAnnotation2dProps;\n const textAnnotationData = parseTextAnnotationData(props.row.textAnnotationData);\n if (textAnnotationData) {\n elProps.textAnnotationData = JSON.stringify(textAnnotationData);\n }\n return elProps;\n }\n\n /**\n * TextAnnotation2d serializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: TextAnnotation2dProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.textAnnotationData !== undefined) {\n inst.textAnnotationData = props.textAnnotationData;\n }\n return inst;\n }\n\n /** @internal */\n public getTextBlocks(): Iterable<TextBlockAndId> {\n return getTextBlocks(this);\n }\n\n /** @internal */\n public updateTextBlocks(textBlocks: TextBlockAndId[]): void {\n return updateTextBlocks(this, textBlocks);\n }\n\n /** @internal */\n public static override onInserted(arg: OnElementIdArg): void {\n super.onInserted(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n /** @internal */\n public static override onUpdated(arg: OnElementIdArg): void {\n super.onUpdated(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n collectReferenceIds(this, referenceIds);\n }\n\n /** @internal */\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: TextAnnotation2dProps, dstProps: TextAnnotation2dProps): Promise<void> {\n await super.onCloned(context, srcProps, dstProps);\n\n const srcElem = TextAnnotation2d.fromJSON(srcProps, context.sourceDb);\n ElementDrivesTextAnnotation.remapFields(srcElem, context);\n const anno = srcElem.getAnnotation();\n dstProps.textAnnotationData = anno ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: anno.toJSON() }) : undefined;\n\n return remapTextStyle(context, srcElem, dstProps);\n }\n}\n\n/** An element that displays textual content within a 3d model.\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\n * @see [[setAnnotation]] to change the textual content.\n * @public @preview\n */\nexport class TextAnnotation3d extends GraphicalElement3d /* implements ITextAnnotation */ {\n /** @internal */\n public static override get className(): string { return \"TextAnnotation3d\"; }\n /**\n * The default [[AnnotationTextStyle]] used by the TextAnnotation3d.\n * @beta\n */\n public defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\n /** The data associated with the text annotation. */\n private _textAnnotationProps?: TextAnnotationProps;\n\n /** Extract the textual content, if present.\n * @see [[setAnnotation]] to change it.\n */\n public getAnnotation(): TextAnnotation | undefined {\n return this._textAnnotationProps ? TextAnnotation.fromJSON(this._textAnnotationProps) : undefined;\n }\n\n /** Change the textual content of the `TextAnnotation3d`.\n * @see [[getAnnotation]] to extract the current annotation.\n * @param annotation The new annotation\n */\n public setAnnotation(annotation: TextAnnotation) {\n this._textAnnotationProps = annotation.toJSON();\n }\n\n protected constructor(props: TextAnnotation3dProps, iModel: IModelDb) {\n super(props, iModel);\n if (props.defaultTextStyle) {\n this.defaultTextStyle = new TextAnnotationUsesTextStyleByDefault(props.defaultTextStyle.id);\n }\n this._textAnnotationProps = parseTextAnnotationData(props.textAnnotationData)?.data;\n }\n\n /** Creates a new instance of `TextAnnotation3d` from its JSON representation. */\n public static fromJSON(props: TextAnnotation3dProps, iModel: IModelDb): TextAnnotation3d {\n return new TextAnnotation3d(props, iModel);\n }\n\n /**\n * Converts the current `TextAnnotation3d` instance to its JSON representation.\n * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.\n * @inheritdoc\n */\n public override toJSON(): TextAnnotation3dProps {\n const props = super.toJSON() as TextAnnotation3dProps;\n props.textAnnotationData = this._textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: this._textAnnotationProps }) : undefined;\n if (this._textAnnotationProps) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.category, this.placement, this._textAnnotationProps, this.defaultTextStyle ? this.defaultTextStyle.id : undefined);\n }\n\n return props;\n }\n\n /** Creates a new `TextAnnotation3d` instance with the specified properties.\n * @param iModelDb The iModel.\n * @param arg The arguments for creating the TextAnnotation3d.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextAnnotation3dCreateArgs): TextAnnotation3d {\n const elementProps: TextAnnotation3dProps = {\n classFullName: this.classFullName,\n textAnnotationData: arg.textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: arg.textAnnotationProps }) : undefined,\n defaultTextStyle: arg.defaultTextStyleId ? new TextAnnotationUsesTextStyleByDefault(arg.defaultTextStyleId).toJSON() : undefined,\n placement: arg.placement,\n model: arg.model,\n category: arg.category,\n code: arg.code ?? Code.createEmpty(),\n };\n return new this(elementProps, iModelDb);\n }\n\n /**\n * Updates the geometry of the TextAnnotation3d on insert and validates version..\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Updates the geometry of the TextAnnotation3d on update and validates version..\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation3dProps]($common).\n * Only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.\n * Also, validates the version of the text annotation data and migrates it if necessary.\n * @beta\n */\n protected static validateVersionAndUpdateGeometry(arg: OnElementPropsArg): void {\n const props = arg.props as TextAnnotation3dProps;\n const textAnnotationData = parseTextAnnotationData(props.textAnnotationData);\n if (!props.elementGeometryBuilderParams && textAnnotationData) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(arg.iModel, props.model, props.category, props.placement ?? Placement3d.fromJSON(), textAnnotationData.data, props.defaultTextStyle?.id);\n }\n }\n\n /**\n * TextAnnotation3d custom HandledProps include 'textAnnotationData'.\n * @inheritdoc\n * @internal\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"textAnnotationData\", source: \"Class\" },\n ];\n\n /**\n * TextAnnotation3d deserializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): TextAnnotation3dProps {\n const elProps = super.deserialize(props) as TextAnnotation3dProps;\n const textAnnotationData = parseTextAnnotationData(props.row.textAnnotationData);\n if (textAnnotationData) {\n elProps.textAnnotationData = JSON.stringify(textAnnotationData);\n }\n return elProps;\n }\n\n /**\n * TextAnnotation3d serializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: TextAnnotation3dProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.textAnnotationData !== undefined) {\n inst.textAnnotationData = props.textAnnotationData;\n }\n return inst;\n }\n\n /** @internal */\n public getTextBlocks(): Iterable<TextBlockAndId> {\n return getTextBlocks(this);\n }\n\n /** @internal */\n public updateTextBlocks(textBlocks: TextBlockAndId[]): void {\n return updateTextBlocks(this, textBlocks);\n }\n\n /** @internal */\n public static override onInserted(arg: OnElementIdArg): void {\n super.onInserted(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n /** @internal */\n public static override onUpdated(arg: OnElementIdArg): void {\n super.onUpdated(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n collectReferenceIds(this, referenceIds);\n }\n\n /** @internal */\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: TextAnnotation3dProps, dstProps: TextAnnotation3dProps): Promise<void> {\n await super.onCloned(context, srcProps, dstProps);\n\n const srcElem = TextAnnotation3d.fromJSON(srcProps, context.sourceDb);\n ElementDrivesTextAnnotation.remapFields(srcElem, context);\n const anno = srcElem.getAnnotation();\n dstProps.textAnnotationData = anno ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: anno.toJSON() }) : undefined;\n\n return remapTextStyle(context, srcElem, dstProps);\n }\n}\n\nasync function remapTextStyle(\n context: IModelElementCloneContext,\n srcElem: TextAnnotation2d | TextAnnotation3d,\n dstProps: TextAnnotation2dProps | TextAnnotation3dProps\n): Promise<void> {\n const dstStyleId = await AnnotationTextStyle.remapTextStyleId(srcElem.defaultTextStyle?.id ?? Id64.invalid, context);\n dstProps.defaultTextStyle = Id64.isValid(dstStyleId) ? new TextAnnotationUsesTextStyleByDefault(dstStyleId).toJSON() : undefined;\n}\n\nfunction collectReferenceIds(elem: TextAnnotation2d | TextAnnotation3d, referenceIds: EntityReferenceSet): void {\n const style = elem.defaultTextStyle?.id;\n if (style && Id64.isValidId64(style)) {\n referenceIds.addElement(style);\n }\n\n const block = elem.getAnnotation()?.textBlock;\n if (block) {\n for (const { child } of traverseTextBlockComponent(block)) {\n if (child.type === \"field\") {\n const hostId = child.propertyHost.elementId;\n if (Id64.isValidId64(hostId)) {\n referenceIds.addElement(hostId);\n }\n }\n }\n }\n}\n\nfunction getTextBlocks(elem: TextAnnotation2d | TextAnnotation3d): Iterable<TextBlockAndId> {\n const annotation = elem.getAnnotation();\n return annotation ? [{ textBlock: annotation.textBlock, id: undefined }] : [];\n}\n\nfunction updateTextBlocks(elem: TextAnnotation2d | TextAnnotation3d, textBlocks: TextBlockAndId[]): void {\n assert(textBlocks.length === 1);\n assert(textBlocks[0].id === undefined);\n\n const annotation = elem.getAnnotation();\n if (!annotation) {\n // We must obtain the TextBlockAndId from the element in the first place, so the only way we could end up here is if\n // somebody removed the text annotation after we called getTextBlocks. That's gotta be a mistake.\n throw new Error(\"Text annotation element has no text\");\n }\n\n annotation.textBlock = textBlocks[0].textBlock;\n\n elem.setAnnotation(annotation);\n}\n\n/** The version of the JSON stored in `AnnotationTextStyleProps.settings` used by the code.\n * Uses the same semantics as [ECVersion]($ecschema-metadata).\n * @internal\n*/\n// 1.0.1 - Added terminatorShapes for leaders\nexport const TEXT_STYLE_SETTINGS_JSON_VERSION = \"1.0.1\";\n\nfunction migrateTextStyleSettings(oldData: VersionedJSON<TextStyleSettingsProps>): TextStyleSettingsProps {\n if (oldData.version === TEXT_STYLE_SETTINGS_JSON_VERSION) return oldData.data;\n\n // Migrate from 1.0.0 to 1.0.1\n if (oldData.data.leader && !oldData.data.leader.terminatorShape) {\n oldData.data.leader.terminatorShape = TextStyleSettings.defaultProps.leader.terminatorShape;\n }\n return oldData.data;\n\n}\n\n/** Arguments supplied when creating an [[AnnotationTextStyle]].\n * @beta\n */\nexport interface TextStyleCreateArgs {\n /** The ID of the [[DefinitionModel]]. */\n definitionModelId: Id64String;\n /** The name to assign to the [[AnnotationTextStyle]]. */\n name: string;\n /** Optional text style settings used to create the [[AnnotationTextStyle]]. Default settings will be used if not provided. */\n settings?: TextStyleSettingsProps;\n /** Optional description for the [[AnnotationTextStyle]]. */\n description?: string;\n}\n\n/**\n * The definition element that holds text style information.\n * The style is stored as a [TextStyleSettings]($common).\n * @beta\n */\nexport class AnnotationTextStyle extends DefinitionElement {\n /** @internal */\n public static override get className(): string { return \"AnnotationTextStyle\"; }\n /**\n * Optional text describing the `AnnotationTextStyle`.\n */\n public description?: string;\n /**\n * The text style settings for the `AnnotationTextStyle`.\n * @see [[TextStyleSettings]] for more information.\n */\n public settings: TextStyleSettings;\n\n protected constructor(props: AnnotationTextStyleProps, iModel: IModelDb) {\n super(props, iModel);\n this.description = props.description;\n const settingsProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);\n this.settings = TextStyleSettings.fromJSON(settingsProps?.data);\n }\n\n /**\n * Creates a Code for an `AnnotationTextStyle` given a name that is meant to be unique within the scope of the specified DefinitionModel.\n *\n * @param iModel - The IModelDb.\n * @param definitionModelId - The ID of the DefinitionModel that contains the AnnotationTextStyle and provides the scope for its name.\n * @param name - The AnnotationTextStyle name.\n * @beta\n */\n public static createCode(iModel: IModelDb, definitionModelId: CodeScopeProps, name: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.annotationTextStyle);\n return new Code({ spec: codeSpec.id, scope: definitionModelId, value: name });\n }\n\n /**\n * Creates a new instance of `AnnotationTextStyle` with the specified properties.\n *\n * @param iModelDb - The iModelDb.\n * @param arg - The arguments for creating the AnnotationTextStyle.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextStyleCreateArgs): AnnotationTextStyle {\n const props: AnnotationTextStyleProps = {\n classFullName: this.classFullName,\n model: arg.definitionModelId,\n code: this.createCode(iModelDb, arg.definitionModelId, arg.name).toJSON(),\n description: arg.description,\n settings: arg.settings ? JSON.stringify({ version: TEXT_STYLE_SETTINGS_JSON_VERSION, data: arg.settings }) : undefined,\n }\n return new this(props, iModelDb);\n }\n\n /**\n * Converts the current `AnnotationTextStyle` instance to its JSON representation.\n * @inheritdoc\n */\n public override toJSON(): AnnotationTextStyleProps {\n const props = super.toJSON() as AnnotationTextStyleProps;\n props.description = this.description;\n props.settings = JSON.stringify({ version: TEXT_STYLE_SETTINGS_JSON_VERSION, data: this.settings.toJSON() });\n return props;\n }\n\n /** Creates a new instance of `AnnotationTextStyle` from its JSON representation. */\n public static fromJSON(props: AnnotationTextStyleProps, iModel: IModelDb): AnnotationTextStyle {\n return new AnnotationTextStyle(props, iModel);\n }\n\n /**\n * Validates that the AnnotationTextStyle's settings are valid before insert.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateSettings(arg.props as AnnotationTextStyleProps);\n }\n\n /**\n * Validates that the AnnotationTextStyle's settings are valid before update.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateSettings(arg.props as AnnotationTextStyleProps);\n }\n\n private static validateSettings(props: AnnotationTextStyleProps): void {\n const settingProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);\n if (!settingProps) return;\n const settings = TextStyleSettings.fromJSON(settingProps.data);\n const errors = settings.getValidationErrors();\n if (errors.length > 0) {\n throw new Error(`Invalid AnnotationTextStyle settings: ${errors.join(\", \")}`);\n }\n }\n\n /**\n * AnnotationTextStyle custom HandledProps include 'settings'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"settings\", source: \"Class\" },\n ];\n\n /**\n * AnnotationTextStyle deserializes 'settings'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): AnnotationTextStyleProps {\n const elProps = super.deserialize(props) as AnnotationTextStyleProps;\n const settings = this.parseTextStyleSettings(props.row.settings);\n if (settings) {\n elProps.settings = JSON.stringify(settings);\n }\n return elProps;\n }\n\n /**\n * AnnotationTextStyle serializes 'settings'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: AnnotationTextStyleProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.settings !== undefined) {\n inst.settings = props.settings;\n }\n return inst;\n }\n\n /** Parses, validates, and potentially migrates the text style settings data from a JSON string. */\n private static parseTextStyleSettings(json: string | undefined): VersionedJSON<TextStyleSettingsProps> | undefined {\n if (!json) return undefined;\n return validateAndMigrateVersionedJSON<TextStyleSettingsProps>(json, TEXT_STYLE_SETTINGS_JSON_VERSION, migrateTextStyleSettings);\n }\n\n /** When copying an element from one iModel to another, returns the Id of the AnnotationTextStyle in the `context`'s target iModel\n * corresponding to `sourceTextStyleId`, or [Id64.invalid]($bentley) if no corresponding text style exists.\n * If a text style with the same [Code]($common) exists in the target iModel, the style Id will be remapped to refer to that style.\n * Otherwise, a copy of the style will be imported into the target iModel and its element Id returned.\n * Implementations of [[ITextAnnotation]] should invoke this function when implementing their [[Element.onCloned]] method.\n * @throws Error if an attempt to import the text style failed.\n */\n public static async remapTextStyleId(sourceTextStyleId: Id64String, context: IModelElementCloneContext): Promise<Id64String> {\n // No remapping necessary if there's no text style or we're not copying to a different iModel.\n if (!Id64.isValid(sourceTextStyleId) || !context.isBetweenIModels) {\n return sourceTextStyleId;\n }\n\n // If the style's already been remapped, we're finished.\n let dstStyleId: Id64String | undefined = context.findTargetElementId(sourceTextStyleId);\n if (Id64.isValid(dstStyleId)) {\n return dstStyleId;\n }\n\n // Look up the style. It really ought to exist.\n const srcStyle = context.sourceDb.elements.tryGetElement<AnnotationTextStyle>(sourceTextStyleId);\n if (!srcStyle) {\n return Id64.invalid;\n }\n\n // If a style with the same code exists in the target iModel, remap to that one.\n dstStyleId = context.targetDb.elements.queryElementIdByCode(srcStyle.code);\n if (undefined !== dstStyleId) {\n return dstStyleId;\n }\n\n // Copy the style into the target iModel and remap its Id.\n const dstStyleProps = await context.cloneElement(srcStyle);\n dstStyleId = context.targetDb.elements.insertElement(dstStyleProps);\n context.remapElement(sourceTextStyleId, dstStyleId);\n return dstStyleId;\n }\n\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: AnnotationTextStyleProps, dstProps: AnnotationTextStyleProps): Promise<void> {\n await super.onCloned(context, srcProps, dstProps);\n if (!context.isBetweenIModels) {\n return;\n }\n\n const settingsProps = AnnotationTextStyle.parseTextStyleSettings(srcProps.settings);\n const font = TextStyleSettings.fromJSON(settingsProps?.data).font;\n\n const fontsToEmbed = [];\n for (const file of context.sourceDb.fonts.queryEmbeddedFontFiles()) {\n if (file.type === font.type && file.faces.some((face) => face.familyName === font.name)) {\n fontsToEmbed.push(file);\n }\n }\n\n await Promise.all(fontsToEmbed.map(async (file) => context.targetDb.fonts.embedFontFile({ file })));\n }\n}\n"]}
|
|
@@ -196,7 +196,6 @@ describe("LeaderGeometry", () => {
|
|
|
196
196
|
terminatorGeometry = builder.geometries[2];
|
|
197
197
|
}
|
|
198
198
|
if (shape.includes("circle")) {
|
|
199
|
-
// expect(terminatorGeometry).to.be.instanceOf(Arc3d);
|
|
200
199
|
expect(terminatorGeometry.circularRadius()).to.equal(terminatorHeight / 2);
|
|
201
200
|
}
|
|
202
201
|
if (shape === "slash") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LeaderGeometry.test.js","sourceRoot":"","sources":["../../../../src/test/annotations/LeaderGeometry.test.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,QA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AAC;YACjD,MAAM,CAAC,eAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,oDAAoD;QAC9G,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAA;AAEJ,CAAC,CAAC,CAAA","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\nimport { expect } from \"chai\";\nimport { ColorDef, GeometryParams, LineBreakRun, TerminatorShape, terminatorShapes, TextAnnotation, TextAnnotationLeader, TextBlock, TextFrameStyleProps, TextRun, TextStyleSettings } from \"@itwin/core-common\";\nimport { Arc3d, LineSegment3d, LineString3d, Point3d, Range2d, YawPitchRollAngles } from \"@itwin/core-geometry\";\nimport { appendLeadersToBuilder, computeElbowDirection, computeFrame, computeLeaderAttachmentPoint, TextStyleResolver } from \"../../core-backend\";\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\nimport { doLayout, MockBuilder } from \"../AnnotationTestUtils\";\n\ndescribe(\"LeaderGeometry\", () => {\n let builder: MockBuilder;\n let defaultParams: GeometryParams;\n\n const textBlock = TextBlock.create({ styleOverrides: { font: { name: \"Arial\" }, color: ColorDef.black.toJSON(), leader: { wantElbow: false } } });\n textBlock.appendRun(TextRun.create({ content: \"Hello\", styleOverrides: { font: { name: \"Arial\" } } }));\n textBlock.appendRun(LineBreakRun.create({\n styleOverrides: { font: { name: \"Arial\" } },\n }));\n textBlock.appendRun(TextRun.create({ content: \"World\", styleOverrides: { font: { name: \"Arial\" } } }));\n\n const frame: TextFrameStyleProps = { borderWeight: 1, shape: \"rectangle\" };\n\n const annotation = TextAnnotation.fromJSON({\n textBlock: textBlock.toJSON(),\n anchor: { horizontal: \"left\", vertical: \"top\" },\n orientation: YawPitchRollAngles.createDegrees(0, 0, 0).toJSON(),\n offset: { x: 0, y: 0 },\n });\n\n const findTextStyle = (id: Id64String) => TextStyleSettings.fromJSON(id === \"0x34\" ? { lineSpacingFactor: 12, font: { name: \"block\" }, frame } : { lineSpacingFactor: 99, font: { name: \"run\" }, frame });\n const textStyleResolver = new TextStyleResolver({\n textBlock,\n textStyleId: \"0x34\",\n iModel: {} as any,\n findTextStyle,\n });\n const layout = doLayout(textBlock, {\n textStyleId: \"0x34\",\n findTextStyle,\n findFontId: () => 0,\n });\n const scaleFactor = 1;\n\n\n const range = Range2d.fromJSON(layout.range);\n const transform = annotation.computeTransform(range);\n const frameCurve = computeFrame({ frame: frame.shape === \"none\" ? \"rectangle\" : (frame.shape ?? \"rectangle\"), range: layout.range, transform });\n\n beforeEach(() => {\n builder = new MockBuilder();\n defaultParams = new GeometryParams(Id64.invalid);\n });\n\n describe(\"appendLeaderToBuilder\", () => {\n it(\"should append a leader to the builder\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"Nearest\" }\n }\n ]\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const params = builder.params[builder.params.length - 1];\n expect(builder.params.length).to.be.equal(1);\n expect(params.lineColor).to.be.equal(ColorDef.black); // textBlock color\n expect(builder.geometries.length).to.be.equal(2); // One LineString3d for leadersLines and one for terminators\n for (const geometryEntry of builder.geometries) {\n expect(geometryEntry).to.be.instanceOf(LineString3d);\n }\n });\n\n it(\"should append multiple leaders to the builder\", () => {\n const leaders: TextAnnotationLeader[] = [{ startPoint: Point3d.create(20, 20, 0), attachment: { mode: \"Nearest\" } },\n { startPoint: Point3d.create(10, 0, 0), attachment: { mode: \"Nearest\" } }];\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n expect(builder.params.length).to.be.equal(2); // One for each leader\n expect(builder.geometries.length).to.be.equal(4); // Two LineString3d for leadersSegments and two for terminators\n for (const geometryEntry of builder.geometries) {\n expect(geometryEntry).to.be.instanceOf(LineString3d);\n }\n });\n\n it(\"should have intermediate points in geometry\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"Nearest\" },\n intermediatePoints: [Point3d.create(15, 15, 0), Point3d.create(20, 20, 0)]\n }\n ];\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const geometries = builder.geometries;\n const leaderLines = geometries[0] as LineString3d;\n expect(leaderLines.points.length).to.be.equal(4); // start + 2 intermediate + end\n });\n\n it(\"should have elbow in the geometry\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"TextPoint\", position: \"TopLeft\" },\n styleOverrides: {\n leader: {\n wantElbow: true,\n elbowLength: 5\n }\n }\n }\n ];\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const geometries = builder.geometries;\n const leaderLines = geometries[0] as LineString3d;\n expect(leaderLines.points.length).to.be.equal(3); // start + elbowPoint + end\n });\n\n describe(\"should return correct geometry for different attachment modes\", () => {\n const leaders: TextAnnotationLeader[] = [{\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"TextPoint\", position: \"TopLeft\" }\n }, {\n startPoint: Point3d.create(20, 20, 0),\n attachment: { mode: \"KeyPoint\", curveIndex: 0, fraction: 0.5 }\n }, {\n startPoint: Point3d.create(30, 30, 0),\n attachment: { mode: \"Nearest\" }\n }]\n\n for (const leader of leaders) {\n builder = new MockBuilder();\n it(`${leader.attachment.mode}`, () => {\n const attachmentPoint = computeLeaderAttachmentPoint(leader, frameCurve, layout, transform);\n if (!attachmentPoint) {\n expect.fail(\"Attachment point should not be undefined\");\n }\n const result = appendLeadersToBuilder(builder, [leader], layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const leaderLines = builder.geometries[0] as LineString3d;\n // The last point in the geometry is the point on frame where leader is supposed to be attached.\n expect(leaderLines.points[leaderLines.points.length - 1].isAlmostEqual(attachmentPoint)).to.be.true;\n })\n }\n })\n describe(\"should return correct geometry for different styleOverrides\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"TextPoint\", position: \"TopLeft\" },\n styleOverrides: {\n leader: {\n wantElbow: true,\n elbowLength: 5,\n color: ColorDef.red.toJSON(),\n terminatorShape: terminatorShapes[0],\n terminatorHeightFactor: 2,\n terminatorWidthFactor: 2,\n }\n }\n }\n ];\n\n it(\"should apply color overrides\", () => {\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const params = builder.params[builder.params.length - 1];\n expect(params.lineColor).to.equal(ColorDef.red);\n });\n\n it(\"should apply terminator size overrides\", () => {\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const terminatorLines = builder.geometries[1] as LineString3d;\n const terminatorLength = LineSegment3d.create(terminatorLines.points[0], terminatorLines.points[1]).curveLength();\n const textHeight = 1;\n const terminatorWidth = (leaders[0].styleOverrides?.leader?.terminatorWidthFactor ?? 1) * textHeight;\n const terminatorHeight = (leaders[0].styleOverrides?.leader?.terminatorHeightFactor ?? 1) * textHeight;\n // terminator length is calculated based on the terminator width and height factors.\n const expectedTerminatorLength = Math.sqrt(terminatorWidth * terminatorWidth + ((terminatorHeight / 2) * (terminatorHeight / 2)));\n expect(terminatorLength).to.be.closeTo(expectedTerminatorLength, 0.01);\n });\n\n it(\"should apply elbow length overrides\", () => {\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const leaderLines = builder.geometries[0] as LineString3d;\n // When elbow exists, the last two points in the leaderLines should form the elbow\n const elbowLine = LineSegment3d.create(leaderLines.points[leaderLines.points.length - 1], leaderLines.points[leaderLines.points.length - 2]);\n const elbowLength = elbowLine.curveLength();\n expect(elbowLength).to.be.closeTo(leaders[0].styleOverrides?.leader?.elbowLength ?? 1, 0.01);\n });\n\n it(\"should apply terminator shape overrides\", () => {\n const textHeight = 1;\n const terminatorHeight = (leaders[0].styleOverrides?.leader?.terminatorHeightFactor ?? 1) * textHeight;\n const terminatorWidth = (leaders[0].styleOverrides?.leader?.terminatorWidthFactor ?? 1) * textHeight;\n let firstLeaderLineLengthBeforeTruncation: number;\n terminatorShapes.forEach((shape: TerminatorShape) => {\n it(`Terminator shape: ${shape}`, () => {\n leaders[0].styleOverrides = { ...leaders[0].styleOverrides, leader: { terminatorShape: shape } };\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n if (shape === \"none\") {\n expect(builder.geometries.length).to.equal(1); // Only leader line should be present with no terminators\n } else {\n let terminatorGeometry = builder.geometries[1];\n if (shape.includes(\"Filled\")) {\n expect(builder.geometries.length).to.equal(3) // One entry for geometry query and another for geometryParams for fill\n terminatorGeometry = builder.geometries[2];\n }\n if (shape.includes(\"circle\")) {\n // expect(terminatorGeometry).to.be.instanceOf(Arc3d);\n expect((terminatorGeometry as Arc3d).circularRadius()).to.equal(terminatorHeight / 2)\n }\n\n if (shape === \"slash\") {\n expect(terminatorGeometry).to.be.instanceOf(LineSegment3d);\n terminatorGeometry = terminatorGeometry as LineSegment3d;\n expect(terminatorGeometry.curveLength()).to.equal(terminatorHeight);\n }\n\n if (shape === \"closedArrow\") {\n // The leaderLine is truncated to accommodate the closed and hollow shape of the terminator\n const leaderLine = builder.geometries[0] as LineString3d;\n const firstLeaderLine = LineSegment3d.create(leaderLine.points[0], leaderLine.points[1]);\n const firstLeaderLineLength = firstLeaderLine.curveLength();\n expect(firstLeaderLineLength).to.be.closeTo(firstLeaderLineLengthBeforeTruncation - terminatorWidth, 0.01);\n } else {\n // keep record of first leader line length before truncation for closedArrow test\n const leaderLine = builder.geometries[0] as LineString3d;\n const firstLeaderLineBeforeTruncation = LineSegment3d.create(leaderLine.points[0], leaderLine.points[1]);\n firstLeaderLineLengthBeforeTruncation = firstLeaderLineBeforeTruncation.curveLength();\n }\n }\n\n });\n\n });\n });\n\n });\n });\n\n describe(\"computeElbowDirection\", () => {\n it(\"should return elbow direction\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"TextPoint\", position: \"TopLeft\" },\n styleOverrides: {\n leader: {\n wantElbow: true,\n elbowLength: 5\n }\n }\n }\n ];\n\n const attachmentPoint = computeLeaderAttachmentPoint(leaders[0], frameCurve, layout, transform);\n if (attachmentPoint) {\n const elbowDirection = computeElbowDirection(attachmentPoint, frameCurve,\n leaders[0].styleOverrides?.leader?.elbowLength ?? 1);\n expect(elbowDirection).to.exist;\n }\n });\n\n it(\"should return undefined if elbow is tangential\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"Nearest\" },\n styleOverrides: {\n leader: {\n wantElbow: true,\n elbowLength: 5\n }\n }\n }\n ];\n\n const attachmentPoint = computeLeaderAttachmentPoint(leaders[0], frameCurve, layout, transform);\n if (attachmentPoint) {\n const elbowDirection = computeElbowDirection(attachmentPoint, frameCurve,\n leaders[0].styleOverrides?.leader?.elbowLength ?? 1);\n expect(elbowDirection).to.be.undefined;\n }\n });\n })\n\n describe(\"computeLeaderAttachmentPoint\", () => {\n it(\"should return correct attachmentPoint for 'Nearest' mode\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(-20, 0, 0),\n attachment: { mode: \"Nearest\" }\n }\n ];\n const attachmentPoint = computeLeaderAttachmentPoint(leaders[0], frameCurve, layout, transform);\n expect(attachmentPoint).to.exist;\n expect(attachmentPoint!.isAlmostEqual(Point3d.create(0, 0, 0))).to.be.true;\n });\n\n it(\"should return correct attachmentPoint for 'Keypoint' mode\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(-20, 0, 0),\n attachment: { mode: \"KeyPoint\", curveIndex: 0, fraction: 0 }\n }\n ];\n const attachmentPoint = computeLeaderAttachmentPoint(leaders[0], frameCurve, layout, transform);\n expect(attachmentPoint).to.exist;\n expect(attachmentPoint?.y).to.be.equal(range.low.y); // expected to be at the bottom of the TextBlock\n });\n\n it(\"should return correct attachmentPoint for 'TextPoint' mode\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(-20, 0, 0),\n attachment: { mode: \"TextPoint\", position: \"TopLeft\" }\n }\n ];\n const attachmentPoint = computeLeaderAttachmentPoint(leaders[0], frameCurve, layout, transform);\n expect(attachmentPoint).to.exist;\n const topY = range.high.y;\n const middleY = (range.low.y + range.high.y) / 2;\n expect(attachmentPoint!.y).to.be.within(middleY, topY); // expected to be in the upper half of the TextBlock\n });\n })\n\n})\n"]}
|
|
1
|
+
{"version":3,"file":"LeaderGeometry.test.js","sourceRoot":"","sources":["../../../../src/test/annotations/LeaderGeometry.test.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAmB,gBAAgB,EAAE,cAAc,EAAwB,SAAS,EAAuB,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACjN,OAAO,EAAS,aAAa,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAChH,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,YAAY,EAAE,4BAA4B,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAClJ,OAAO,EAAE,IAAI,EAAc,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAA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,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;YACjC,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,gDAAgD;QACvG,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;YACpE,MAAM,OAAO,GAA2B;gBACtC;oBACE,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;oBACrC,UAAU,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE;iBACvD;aACF,CAAC;YACF,MAAM,eAAe,GAAG,4BAA4B,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;YAChG,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;YACjC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;YAC1B,MAAM,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YACjD,MAAM,CAAC,eAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,oDAAoD;QAC9G,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAA;AAEJ,CAAC,CAAC,CAAA","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\nimport { expect } from \"chai\";\nimport { ColorDef, GeometryParams, LineBreakRun, TerminatorShape, terminatorShapes, TextAnnotation, TextAnnotationLeader, TextBlock, TextFrameStyleProps, TextRun, TextStyleSettings } from \"@itwin/core-common\";\nimport { Arc3d, LineSegment3d, LineString3d, Point3d, Range2d, YawPitchRollAngles } from \"@itwin/core-geometry\";\nimport { appendLeadersToBuilder, computeElbowDirection, computeFrame, computeLeaderAttachmentPoint, TextStyleResolver } from \"../../core-backend\";\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\nimport { doLayout, MockBuilder } from \"../AnnotationTestUtils\";\n\ndescribe(\"LeaderGeometry\", () => {\n let builder: MockBuilder;\n let defaultParams: GeometryParams;\n\n const textBlock = TextBlock.create({ styleOverrides: { font: { name: \"Arial\" }, color: ColorDef.black.toJSON(), leader: { wantElbow: false } } });\n textBlock.appendRun(TextRun.create({ content: \"Hello\", styleOverrides: { font: { name: \"Arial\" } } }));\n textBlock.appendRun(LineBreakRun.create({\n styleOverrides: { font: { name: \"Arial\" } },\n }));\n textBlock.appendRun(TextRun.create({ content: \"World\", styleOverrides: { font: { name: \"Arial\" } } }));\n\n const frame: TextFrameStyleProps = { borderWeight: 1, shape: \"rectangle\" };\n\n const annotation = TextAnnotation.fromJSON({\n textBlock: textBlock.toJSON(),\n anchor: { horizontal: \"left\", vertical: \"top\" },\n orientation: YawPitchRollAngles.createDegrees(0, 0, 0).toJSON(),\n offset: { x: 0, y: 0 },\n });\n\n const findTextStyle = (id: Id64String) => TextStyleSettings.fromJSON(id === \"0x34\" ? { lineSpacingFactor: 12, font: { name: \"block\" }, frame } : { lineSpacingFactor: 99, font: { name: \"run\" }, frame });\n const textStyleResolver = new TextStyleResolver({\n textBlock,\n textStyleId: \"0x34\",\n iModel: {} as any,\n findTextStyle,\n });\n const layout = doLayout(textBlock, {\n textStyleId: \"0x34\",\n findTextStyle,\n findFontId: () => 0,\n });\n const scaleFactor = 1;\n\n\n const range = Range2d.fromJSON(layout.range);\n const transform = annotation.computeTransform(range);\n const frameCurve = computeFrame({ frame: frame.shape === \"none\" ? \"rectangle\" : (frame.shape ?? \"rectangle\"), range: layout.range, transform });\n\n beforeEach(() => {\n builder = new MockBuilder();\n defaultParams = new GeometryParams(Id64.invalid);\n });\n\n describe(\"appendLeaderToBuilder\", () => {\n it(\"should append a leader to the builder\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"Nearest\" }\n }\n ]\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const params = builder.params[builder.params.length - 1];\n expect(builder.params.length).to.be.equal(1);\n expect(params.lineColor).to.be.equal(ColorDef.black); // textBlock color\n expect(builder.geometries.length).to.be.equal(2); // One LineString3d for leadersLines and one for terminators\n for (const geometryEntry of builder.geometries) {\n expect(geometryEntry).to.be.instanceOf(LineString3d);\n }\n });\n\n it(\"should append multiple leaders to the builder\", () => {\n const leaders: TextAnnotationLeader[] = [{ startPoint: Point3d.create(20, 20, 0), attachment: { mode: \"Nearest\" } },\n { startPoint: Point3d.create(10, 0, 0), attachment: { mode: \"Nearest\" } }];\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n expect(builder.params.length).to.be.equal(2); // One for each leader\n expect(builder.geometries.length).to.be.equal(4); // Two LineString3d for leadersSegments and two for terminators\n for (const geometryEntry of builder.geometries) {\n expect(geometryEntry).to.be.instanceOf(LineString3d);\n }\n });\n\n it(\"should have intermediate points in geometry\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"Nearest\" },\n intermediatePoints: [Point3d.create(15, 15, 0), Point3d.create(20, 20, 0)]\n }\n ];\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const geometries = builder.geometries;\n const leaderLines = geometries[0] as LineString3d;\n expect(leaderLines.points.length).to.be.equal(4); // start + 2 intermediate + end\n });\n\n it(\"should have elbow in the geometry\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"TextPoint\", position: \"TopLeft\" },\n styleOverrides: {\n leader: {\n wantElbow: true,\n elbowLength: 5\n }\n }\n }\n ];\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const geometries = builder.geometries;\n const leaderLines = geometries[0] as LineString3d;\n expect(leaderLines.points.length).to.be.equal(3); // start + elbowPoint + end\n });\n\n describe(\"should return correct geometry for different attachment modes\", () => {\n const leaders: TextAnnotationLeader[] = [{\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"TextPoint\", position: \"TopLeft\" }\n }, {\n startPoint: Point3d.create(20, 20, 0),\n attachment: { mode: \"KeyPoint\", curveIndex: 0, fraction: 0.5 }\n }, {\n startPoint: Point3d.create(30, 30, 0),\n attachment: { mode: \"Nearest\" }\n }]\n\n for (const leader of leaders) {\n builder = new MockBuilder();\n it(`${leader.attachment.mode}`, () => {\n const attachmentPoint = computeLeaderAttachmentPoint(leader, frameCurve, layout, transform);\n if (!attachmentPoint) {\n expect.fail(\"Attachment point should not be undefined\");\n }\n const result = appendLeadersToBuilder(builder, [leader], layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const leaderLines = builder.geometries[0] as LineString3d;\n // The last point in the geometry is the point on frame where leader is supposed to be attached.\n expect(leaderLines.points[leaderLines.points.length - 1].isAlmostEqual(attachmentPoint)).to.be.true;\n })\n }\n })\n describe(\"should return correct geometry for different styleOverrides\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"TextPoint\", position: \"TopLeft\" },\n styleOverrides: {\n leader: {\n wantElbow: true,\n elbowLength: 5,\n color: ColorDef.red.toJSON(),\n terminatorShape: terminatorShapes[0],\n terminatorHeightFactor: 2,\n terminatorWidthFactor: 2,\n }\n }\n }\n ];\n\n it(\"should apply color overrides\", () => {\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const params = builder.params[builder.params.length - 1];\n expect(params.lineColor).to.equal(ColorDef.red);\n });\n\n it(\"should apply terminator size overrides\", () => {\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const terminatorLines = builder.geometries[1] as LineString3d;\n const terminatorLength = LineSegment3d.create(terminatorLines.points[0], terminatorLines.points[1]).curveLength();\n const textHeight = 1;\n const terminatorWidth = (leaders[0].styleOverrides?.leader?.terminatorWidthFactor ?? 1) * textHeight;\n const terminatorHeight = (leaders[0].styleOverrides?.leader?.terminatorHeightFactor ?? 1) * textHeight;\n // terminator length is calculated based on the terminator width and height factors.\n const expectedTerminatorLength = Math.sqrt(terminatorWidth * terminatorWidth + ((terminatorHeight / 2) * (terminatorHeight / 2)));\n expect(terminatorLength).to.be.closeTo(expectedTerminatorLength, 0.01);\n });\n\n it(\"should apply elbow length overrides\", () => {\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const leaderLines = builder.geometries[0] as LineString3d;\n // When elbow exists, the last two points in the leaderLines should form the elbow\n const elbowLine = LineSegment3d.create(leaderLines.points[leaderLines.points.length - 1], leaderLines.points[leaderLines.points.length - 2]);\n const elbowLength = elbowLine.curveLength();\n expect(elbowLength).to.be.closeTo(leaders[0].styleOverrides?.leader?.elbowLength ?? 1, 0.01);\n });\n\n it(\"should apply terminator shape overrides\", () => {\n const textHeight = 1;\n const terminatorHeight = (leaders[0].styleOverrides?.leader?.terminatorHeightFactor ?? 1) * textHeight;\n const terminatorWidth = (leaders[0].styleOverrides?.leader?.terminatorWidthFactor ?? 1) * textHeight;\n let firstLeaderLineLengthBeforeTruncation: number;\n terminatorShapes.forEach((shape: TerminatorShape) => {\n it(`Terminator shape: ${shape}`, () => {\n leaders[0].styleOverrides = { ...leaders[0].styleOverrides, leader: { terminatorShape: shape } };\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n if (shape === \"none\") {\n expect(builder.geometries.length).to.equal(1); // Only leader line should be present with no terminators\n } else {\n let terminatorGeometry = builder.geometries[1];\n if (shape.includes(\"Filled\")) {\n expect(builder.geometries.length).to.equal(3) // One entry for geometry query and another for geometryParams for fill\n terminatorGeometry = builder.geometries[2];\n }\n if (shape.includes(\"circle\")) {\n expect((terminatorGeometry as Arc3d).circularRadius()).to.equal(terminatorHeight / 2)\n }\n\n if (shape === \"slash\") {\n expect(terminatorGeometry).to.be.instanceOf(LineSegment3d);\n terminatorGeometry = terminatorGeometry as LineSegment3d;\n expect(terminatorGeometry.curveLength()).to.equal(terminatorHeight);\n }\n\n if (shape === \"closedArrow\") {\n // The leaderLine is truncated to accommodate the closed and hollow shape of the terminator\n const leaderLine = builder.geometries[0] as LineString3d;\n const firstLeaderLine = LineSegment3d.create(leaderLine.points[0], leaderLine.points[1]);\n const firstLeaderLineLength = firstLeaderLine.curveLength();\n expect(firstLeaderLineLength).to.be.closeTo(firstLeaderLineLengthBeforeTruncation - terminatorWidth, 0.01);\n } else {\n // keep record of first leader line length before truncation for closedArrow test\n const leaderLine = builder.geometries[0] as LineString3d;\n const firstLeaderLineBeforeTruncation = LineSegment3d.create(leaderLine.points[0], leaderLine.points[1]);\n firstLeaderLineLengthBeforeTruncation = firstLeaderLineBeforeTruncation.curveLength();\n }\n }\n\n });\n\n });\n });\n\n });\n });\n\n describe(\"computeElbowDirection\", () => {\n it(\"should return elbow direction\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"TextPoint\", position: \"TopLeft\" },\n styleOverrides: {\n leader: {\n wantElbow: true,\n elbowLength: 5\n }\n }\n }\n ];\n\n const attachmentPoint = computeLeaderAttachmentPoint(leaders[0], frameCurve, layout, transform);\n if (attachmentPoint) {\n const elbowDirection = computeElbowDirection(attachmentPoint, frameCurve,\n leaders[0].styleOverrides?.leader?.elbowLength ?? 1);\n expect(elbowDirection).to.exist;\n }\n });\n\n it(\"should return undefined if elbow is tangential\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"Nearest\" },\n styleOverrides: {\n leader: {\n wantElbow: true,\n elbowLength: 5\n }\n }\n }\n ];\n\n const attachmentPoint = computeLeaderAttachmentPoint(leaders[0], frameCurve, layout, transform);\n if (attachmentPoint) {\n const elbowDirection = computeElbowDirection(attachmentPoint, frameCurve,\n leaders[0].styleOverrides?.leader?.elbowLength ?? 1);\n expect(elbowDirection).to.be.undefined;\n }\n });\n })\n\n describe(\"computeLeaderAttachmentPoint\", () => {\n it(\"should return correct attachmentPoint for 'Nearest' mode\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(-20, 0, 0),\n attachment: { mode: \"Nearest\" }\n }\n ];\n const attachmentPoint = computeLeaderAttachmentPoint(leaders[0], frameCurve, layout, transform);\n expect(attachmentPoint).to.exist;\n expect(attachmentPoint!.isAlmostEqual(Point3d.create(0, 0, 0))).to.be.true;\n });\n\n it(\"should return correct attachmentPoint for 'Keypoint' mode\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(-20, 0, 0),\n attachment: { mode: \"KeyPoint\", curveIndex: 0, fraction: 0 }\n }\n ];\n const attachmentPoint = computeLeaderAttachmentPoint(leaders[0], frameCurve, layout, transform);\n expect(attachmentPoint).to.exist;\n expect(attachmentPoint?.y).to.be.equal(range.low.y); // expected to be at the bottom of the TextBlock\n });\n\n it(\"should return correct attachmentPoint for 'TextPoint' mode\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(-20, 0, 0),\n attachment: { mode: \"TextPoint\", position: \"TopLeft\" }\n }\n ];\n const attachmentPoint = computeLeaderAttachmentPoint(leaders[0], frameCurve, layout, transform);\n expect(attachmentPoint).to.exist;\n const topY = range.high.y;\n const middleY = (range.low.y + range.high.y) / 2;\n expect(attachmentPoint!.y).to.be.within(middleY, topY); // expected to be in the upper half of the TextBlock\n });\n })\n\n})\n"]}
|