@itwin/core-backend 5.1.0-dev.60 → 5.1.0-dev.62
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/ECSqlStatement.d.ts.map +1 -1
- package/lib/cjs/ECSqlStatement.js +1 -0
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +5 -2
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +11 -2
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/LocalHub.d.ts.map +1 -1
- package/lib/cjs/LocalHub.js +6 -4
- package/lib/cjs/LocalHub.js.map +1 -1
- package/lib/cjs/annotations/FrameGeometry.d.ts +1 -2
- package/lib/cjs/annotations/FrameGeometry.d.ts.map +1 -1
- package/lib/cjs/annotations/FrameGeometry.js +3 -4
- package/lib/cjs/annotations/FrameGeometry.js.map +1 -1
- package/lib/cjs/annotations/LeaderGeometry.d.ts +3 -3
- package/lib/cjs/annotations/LeaderGeometry.d.ts.map +1 -1
- package/lib/cjs/annotations/LeaderGeometry.js +17 -8
- package/lib/cjs/annotations/LeaderGeometry.js.map +1 -1
- package/lib/cjs/annotations/TextAnnotationElement.d.ts +148 -10
- package/lib/cjs/annotations/TextAnnotationElement.d.ts.map +1 -1
- package/lib/cjs/annotations/TextAnnotationElement.js +296 -28
- package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -1
- package/lib/cjs/annotations/TextAnnotationGeometry.d.ts +3 -1
- package/lib/cjs/annotations/TextAnnotationGeometry.d.ts.map +1 -1
- package/lib/cjs/annotations/TextAnnotationGeometry.js +13 -14
- package/lib/cjs/annotations/TextAnnotationGeometry.js.map +1 -1
- package/lib/cjs/annotations/TextBlockLayout.d.ts +47 -14
- package/lib/cjs/annotations/TextBlockLayout.d.ts.map +1 -1
- package/lib/cjs/annotations/TextBlockLayout.js +109 -38
- package/lib/cjs/annotations/TextBlockLayout.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/Workspace.d.ts +0 -1
- package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
- package/lib/cjs/workspace/Workspace.js.map +1 -1
- package/lib/esm/ECSqlStatement.d.ts.map +1 -1
- package/lib/esm/ECSqlStatement.js +1 -0
- package/lib/esm/ECSqlStatement.js.map +1 -1
- package/lib/esm/IModelDb.d.ts +5 -2
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +11 -2
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/LocalHub.d.ts.map +1 -1
- package/lib/esm/LocalHub.js +6 -4
- package/lib/esm/LocalHub.js.map +1 -1
- package/lib/esm/annotations/FrameGeometry.d.ts +1 -2
- package/lib/esm/annotations/FrameGeometry.d.ts.map +1 -1
- package/lib/esm/annotations/FrameGeometry.js +3 -4
- package/lib/esm/annotations/FrameGeometry.js.map +1 -1
- package/lib/esm/annotations/LeaderGeometry.d.ts +3 -3
- package/lib/esm/annotations/LeaderGeometry.d.ts.map +1 -1
- package/lib/esm/annotations/LeaderGeometry.js +17 -8
- package/lib/esm/annotations/LeaderGeometry.js.map +1 -1
- package/lib/esm/annotations/TextAnnotationElement.d.ts +148 -10
- package/lib/esm/annotations/TextAnnotationElement.d.ts.map +1 -1
- package/lib/esm/annotations/TextAnnotationElement.js +297 -30
- package/lib/esm/annotations/TextAnnotationElement.js.map +1 -1
- package/lib/esm/annotations/TextAnnotationGeometry.d.ts +3 -1
- package/lib/esm/annotations/TextAnnotationGeometry.d.ts.map +1 -1
- package/lib/esm/annotations/TextAnnotationGeometry.js +13 -14
- package/lib/esm/annotations/TextAnnotationGeometry.js.map +1 -1
- package/lib/esm/annotations/TextBlockLayout.d.ts +47 -14
- package/lib/esm/annotations/TextBlockLayout.d.ts.map +1 -1
- package/lib/esm/annotations/TextBlockLayout.js +107 -37
- package/lib/esm/annotations/TextBlockLayout.js.map +1 -1
- package/lib/esm/rpc-impl/IModelReadRpcImpl.d.ts +1 -1
- package/lib/esm/rpc-impl/IModelReadRpcImpl.js +1 -1
- package/lib/esm/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/esm/test/AnnotationTestUtils.d.ts.map +1 -1
- package/lib/esm/test/AnnotationTestUtils.js +8 -2
- package/lib/esm/test/AnnotationTestUtils.js.map +1 -1
- package/lib/esm/test/annotations/FrameGeometry.test.js +12 -4
- package/lib/esm/test/annotations/FrameGeometry.test.js.map +1 -1
- package/lib/esm/test/annotations/LeaderGeometry.test.js +21 -16
- package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
- package/lib/esm/test/annotations/TextAnnotation.test.js +180 -121
- package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
- package/lib/esm/test/annotations/TextBlock.test.js +249 -142
- package/lib/esm/test/annotations/TextBlock.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangesetReader.test.js +96 -0
- package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
- package/lib/esm/workspace/Workspace.d.ts +0 -1
- package/lib/esm/workspace/Workspace.d.ts.map +1 -1
- package/lib/esm/workspace/Workspace.js.map +1 -1
- package/package.json +17 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LeaderGeometry.js","sourceRoot":"","sources":["../../../src/annotations/LeaderGeometry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAwBH,wDAwDC;AAcD,sDA4BC;AAiBD,oEA8CC;AAvLD,oDAA0H;AAC1H,wDAAyH;AACzH,mDAA+C;AAG/C;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,sBAAsB,CAAC,OAAgC,EAAE,OAA+B,EAAE,MAAuB,EAAE,SAAoB,EAAE,MAAsB,EAAE,KAA2B;IAC1M,IAAI,MA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C,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAE1G,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YACjD,qBAAqB,GAAG,qBAAqB,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC;YAC7G,cAAc,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC;QAC3C,CAAC;QACD,uFAAuF;QACvF,+EAA+E;QAC/E,MAAM,WAAW,GAAG,qBAAqB,CAAC,UAAU,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC,8CAA8C;QACzH,MAAM,gBAAgB,GAAG,6BAAa,CAAC,MAAM,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC;QAClF,MAAM,kBAAkB,GAAG,0BAAU,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;QACvG,eAAe,GAAG,kBAAkB,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC;IACzD,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ElementGeometry\n */\n\nimport { ColorDef, ElementGeometry, GeometryParams, TextAnnotationLeader, TextFrameStyleProps } from \"@itwin/core-common\";\nimport { CurveCurve, LineSegment3d, LineString3d, Loop, Path, Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\nimport { computeFrame } from \"./FrameGeometry\";\nimport { TextBlockLayout } 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 frame - (Optional) The style properties for the text frame. If not provided or set to \"none\", a default rectangle is used.\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, frame?: TextFrameStyleProps): boolean {\n let result = true;\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 if (leader.styleOverrides?.leader?.color !== \"subcategory\" && leader.styleOverrides?.color !== \"subcategory\") {\n const color = leader.styleOverrides?.leader?.color ?? leader.styleOverrides?.color;\n params.lineColor = color ? ColorDef.fromJSON(color) : ColorDef.black;\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 (leader.styleOverrides?.leader?.wantElbow) {\n const elbowLength = (leader.styleOverrides.leader.elbowLength ?? 1) * (leader.styleOverrides.lineHeight ?? 1)\n const elbowDirection = computeElbowDirection(attachmentPoint, frameCurve, elbowLength);\n if (elbowDirection)\n leaderLinePoints.push(attachmentPoint.plusScaled(elbowDirection, elbowLength))\n }\n\n leaderLinePoints.push(attachmentPoint)\n\n result = result && builder.appendGeometryQuery(LineString3d.create(leaderLinePoints));\n\n // Terminator geometry\n const terminatorDirection = Vector3d.createStartEnd(\n leaderLinePoints[0], leaderLinePoints[1]\n ).normalize();\n\n const termY = terminatorDirection?.unitCrossProduct(Vector3d.unitZ());\n if (!termY || !terminatorDirection) continue; // Assuming leaders without terminators is a valid case.\n const terminatorHeight = (leader.styleOverrides?.leader?.terminatorHeightFactor ?? 1) * (leader.styleOverrides?.lineHeight ?? 1);\n const terminatorWidth = (leader.styleOverrides?.leader?.terminatorWidthFactor ?? 1) * (leader.styleOverrides?.lineHeight ?? 1);\n const basePoint = leader.startPoint.plusScaled(terminatorDirection, terminatorWidth);\n const termPointA = basePoint.plusScaled(termY, terminatorHeight);\n const termPointB = basePoint.plusScaled(termY.negate(), terminatorHeight);\n result = result && builder.appendGeometryQuery(LineString3d.create([termPointA, leader.startPoint, termPointB]));\n\n }\n return result;\n}\n\n\n/**\n * Computes the direction vector for an \"elbow\" for leader based on the attachment point and a frame curve.\n * The elbow direction is determined by whether the attachment point is closer to the left or right side of the frame.\n * If the computed elbow would be tangent to the frame at the intersection, no elbow direction is returned.\n *\n * @param attachmentPoint - The point where the leader attaches.\n * @param frameCurve - The frame curve (either a Loop or Path) to which the leader is attached.\n * @param elbowLength - The length of the elbow segment to be created.\n * @returns The direction vector for the elbow, or `undefined` if the elbow would be tangent to the frame.\n * @beta\n */\nexport function computeElbowDirection(attachmentPoint: Point3d, frameCurve: Loop | Path, elbowLength: number): Vector3d | undefined {\n\n let elbowDirection: Vector3d | undefined;\n // Determine the direction based on the closest point's position relative to the frame\n const isCloserToLeft = Math.abs(attachmentPoint.x - frameCurve.range().low.x) < Math.abs(attachmentPoint.x - frameCurve.range().high.x);\n\n // Decide the direction: left (-X) or right (+X)\n elbowDirection = isCloserToLeft ? Vector3d.unitX().negate() : Vector3d.unitX();\n\n // Verify if the elbow is a tangent to the frame, if yes, do not create an elbow\n const elbowPoint = attachmentPoint.plusScaled(elbowDirection, elbowLength);\n const elbowLine = LineSegment3d.create(attachmentPoint, elbowPoint);\n // Find intersection points between the elbow and the frame\n const intersections = CurveCurve.intersectionXYZPairs(elbowLine, false, frameCurve, false);\n // As the elbow will intersect the frame only at one point, we can safely use the first intersection\n const intersection = intersections[0];\n const curveFraction = intersection.detailB.fraction;\n const derivative = intersection.detailB.curve?.fractionToPointAndDerivative(curveFraction);\n const tangent = derivative?.direction.normalize();\n const lineDirection = Vector3d.createStartEnd(elbowLine.point0Ref, elbowLine.point1Ref).normalize();\n if (tangent && lineDirection) {\n const dot = tangent.dotProduct(lineDirection);\n // If the tangent and line direction are aligned (dot product close to 1 or -1), it's tangent\n if (Math.abs(dot) > 0.999) {\n elbowDirection = undefined;\n }\n }\n return elbowDirection;\n}\n\n/**\n * Computes the attachment point for a leader line on a text annotation frame.\n *\n * The attachment point is determined based on the leader's attachment mode:\n * - `\"Nearest\"`: Finds the closest point on the frame curve to the leader's start point.\n * - `\"KeyPoint\"`: Uses a specific curve segment and fraction along that segment to determine the point.\n * - `\"TextPoint\"`: Calculates a point on the text layout (top/bottom, left/right) and projects it onto the frame curve.\n *\n * @param leader - The leader props.\n * @param frameCurve - The curve (Loop or Path) representing the annotation frame.\n * @param textLayout - The layout information for the text block.\n * @param transform - The transform applied to the text layout.\n * @returns The computed attachment point as a `Point3d`, or `undefined` if it cannot be determined.\n * @beta\n */\nexport function computeLeaderAttachmentPoint(\n leader: TextAnnotationLeader,\n frameCurve: Loop | Path,\n textLayout: TextBlockLayout,\n transform: Transform\n): Point3d | undefined {\n let attachmentPoint: Point3d | undefined;\n\n if (leader.attachment.mode === \"Nearest\") {\n attachmentPoint = frameCurve.closestPoint(leader.startPoint)?.point;\n } else if (leader.attachment.mode === \"KeyPoint\") {\n const curves = frameCurve.collectCurvePrimitives(undefined, false, true);\n const curveIndex = leader.attachment.curveIndex;\n const fraction = leader.attachment.fraction;\n if (curveIndex >= curves.length) {\n // If the curveIndex is invalid, use the last curve\n // This is a fallback to avoid out-of-bounds access\n attachmentPoint = curves[curves.length - 1].fractionToPoint(fraction);\n } else {\n attachmentPoint = curves[curveIndex].fractionToPoint(fraction);\n }\n } else { // attachment.mode=\"TextPoint\"\n let scaleDirection = transform.matrix.getColumn(0).negate(); // direction to draw a scaled line from text attachment point to find intersection point on frame\n let lineIndex: number;\n if (leader.attachment.position.includes(\"Top\")) {\n lineIndex = 0\n } else {\n lineIndex = textLayout.lines.length - 1\n }\n const lineRange = textLayout.lines[lineIndex].range;\n const lineOffset = textLayout.lines[lineIndex].offsetFromDocument;\n const origin = transform.multiplyPoint3d(Point3d.fromJSON(lineOffset));\n let attachmentPointOnText = origin.plusScaled(transform.matrix.getColumn(1), ((lineRange.yLength()) / 2));\n\n if (leader.attachment.position.includes(\"Right\")) {\n attachmentPointOnText = attachmentPointOnText.plusScaled(transform.matrix.getColumn(0), lineRange.xLength());\n scaleDirection = scaleDirection.negate();\n }\n // Find the nearest intersection point on the frame to get the correct attachment point\n // Extend the direction vector to create a target point far along the direction\n const targetPoint = attachmentPointOnText.plusScaled(scaleDirection, 1e6); // Scale the direction vector to a large value\n const intersectionLine = LineSegment3d.create(attachmentPointOnText, targetPoint);\n const closestPointDetail = CurveCurve.intersectionXYZPairs(intersectionLine, false, frameCurve, false);\n attachmentPoint = closestPointDetail[0]?.detailA.point;\n }\n return attachmentPoint;\n}"]}
|
|
1
|
+
{"version":3,"file":"LeaderGeometry.js","sourceRoot":"","sources":["../../../src/annotations/LeaderGeometry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAwBH,wDAmEC;AAcD,sDA4BC;AAiBD,oEA8CC;AAlMD,oDAA0I;AAC1I,wDAAyH;AACzH,mDAA+C;AAG/C;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,sBAAsB,CAAC,OAAgC,EAAE,OAA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C;QACvE,IAAI,qBAAqB,GAAG,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAE1G,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YACjD,qBAAqB,GAAG,qBAAqB,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC;YAC7G,cAAc,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC;QAC3C,CAAC;QACD,uFAAuF;QACvF,+EAA+E;QAC/E,MAAM,WAAW,GAAG,qBAAqB,CAAC,UAAU,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC,8CAA8C;QACzH,MAAM,gBAAgB,GAAG,6BAAa,CAAC,MAAM,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC;QAClF,MAAM,kBAAkB,GAAG,0BAAU,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;QACvG,eAAe,GAAG,kBAAkB,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC;IACzD,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ElementGeometry\n */\n\nimport { ColorDef, ElementGeometry, GeometryParams, TextAnnotationLeader, TextFrameStyleProps, TextStyleColor } from \"@itwin/core-common\";\nimport { CurveCurve, LineSegment3d, LineString3d, Loop, Path, Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\nimport { computeFrame } from \"./FrameGeometry\";\nimport { TextBlockLayout, TextStyleResolver } from \"./TextBlockLayout\";\n\n/**\n * Constructs and appends leader lines and their terminators to the provided geometry builder for a text annotation.\n *\n * This function processes an array of `TextAnnotationLeader` objects, computes their attachment points\n * relative to a text frame (or a default rectangular frame if none is provided), and appends the leader\n * line and terminator geometry to the builder. It also applies color overrides if specified\n * in the leader's style overrides.\n *\n * @param builder - The geometry builder to which the leader geometries will be appended.\n * @param leaders - An array of leader properties.\n * @param layout - The layout information for the text block, including its range.\n * @param transform - The transform to apply to the frame and leader geometry.\n * @param params - The geometry parameters, such as color, to use for the leader lines.\n * @param frame - (Optional) The style properties for the text frame. If not provided or set to \"none\", a default rectangle is used.\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): boolean {\n let result = true;\n const scaledLineHeight = textStyleResolver.blockSettings.lineHeight * textStyleResolver.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.resolveTextAnnotationLeaderSettings(leader);\n\n let effectiveColor: TextStyleColor = \"subcategory\";\n\n if (leaderStyle.leader.color === \"inherit\") {\n effectiveColor = leaderStyle.color;\n } else if (leaderStyle.leader.color !== \"subcategory\") {\n effectiveColor = leaderStyle.leader.color;\n }\n\n if (effectiveColor !== \"subcategory\") {\n params.lineColor = ColorDef.fromJSON(effectiveColor);\n result = result && builder.appendGeometryParamsChange(params);\n }\n\n const attachmentPoint = computeLeaderAttachmentPoint(leader, frameCurve, layout, transform);\n if (!attachmentPoint) return false;\n\n // Leader line geometry\n const leaderLinePoints: Point3d[] = [];\n\n leaderLinePoints.push(leader.startPoint)\n\n leader.intermediatePoints?.forEach((point) => {\n leaderLinePoints.push(point);\n });\n\n if (leaderStyle.leader.wantElbow) {\n const elbowLength = leaderStyle.leader.elbowLength * scaledLineHeight;\n const elbowDirection = computeElbowDirection(attachmentPoint, frameCurve, elbowLength);\n if (elbowDirection)\n leaderLinePoints.push(attachmentPoint.plusScaled(elbowDirection, elbowLength))\n }\n\n leaderLinePoints.push(attachmentPoint)\n\n result = result && builder.appendGeometryQuery(LineString3d.create(leaderLinePoints));\n\n // Terminator geometry\n const terminatorDirection = Vector3d.createStartEnd(\n leaderLinePoints[0], leaderLinePoints[1]\n ).normalize();\n\n const termY = terminatorDirection?.unitCrossProduct(Vector3d.unitZ());\n if (!termY || !terminatorDirection) continue; // Assuming leaders without terminators is a valid case.\n const terminatorHeight = leaderStyle.leader.terminatorHeightFactor * scaledLineHeight;\n const terminatorWidth = leaderStyle.leader.terminatorWidthFactor * scaledLineHeight;\n const basePoint = leader.startPoint.plusScaled(terminatorDirection, terminatorWidth);\n const termPointA = basePoint.plusScaled(termY, terminatorHeight);\n const termPointB = basePoint.plusScaled(termY.negate(), terminatorHeight);\n result = result && builder.appendGeometryQuery(LineString3d.create([termPointA, leader.startPoint, termPointB]));\n\n }\n return result;\n}\n\n\n/**\n * Computes the direction vector for an \"elbow\" for leader based on the attachment point and a frame curve.\n * The elbow direction is determined by whether the attachment point is closer to the left or right side of the frame.\n * If the computed elbow would be tangent to the frame at the intersection, no elbow direction is returned.\n *\n * @param attachmentPoint - The point where the leader attaches.\n * @param frameCurve - The frame curve (either a Loop or Path) to which the leader is attached.\n * @param elbowLength - The length of the elbow segment to be created.\n * @returns The direction vector for the elbow, or `undefined` if the elbow would be tangent to the frame.\n * @beta\n */\nexport function computeElbowDirection(attachmentPoint: Point3d, frameCurve: Loop | Path, elbowLength: number): Vector3d | undefined {\n\n let elbowDirection: Vector3d | undefined;\n // Determine the direction based on the closest point's position relative to the frame\n const isCloserToLeft = Math.abs(attachmentPoint.x - frameCurve.range().low.x) < Math.abs(attachmentPoint.x - frameCurve.range().high.x);\n\n // Decide the direction: left (-X) or right (+X)\n elbowDirection = isCloserToLeft ? Vector3d.unitX().negate() : Vector3d.unitX();\n\n // Verify if the elbow is a tangent to the frame, if yes, do not create an elbow\n const elbowPoint = attachmentPoint.plusScaled(elbowDirection, elbowLength);\n const elbowLine = LineSegment3d.create(attachmentPoint, elbowPoint);\n // Find intersection points between the elbow and the frame\n const intersections = CurveCurve.intersectionXYZPairs(elbowLine, false, frameCurve, false);\n // As the elbow will intersect the frame only at one point, we can safely use the first intersection\n const intersection = intersections[0];\n const curveFraction = intersection.detailB.fraction;\n const derivative = intersection.detailB.curve?.fractionToPointAndDerivative(curveFraction);\n const tangent = derivative?.direction.normalize();\n const lineDirection = Vector3d.createStartEnd(elbowLine.point0Ref, elbowLine.point1Ref).normalize();\n if (tangent && lineDirection) {\n const dot = tangent.dotProduct(lineDirection);\n // If the tangent and line direction are aligned (dot product close to 1 or -1), it's tangent\n if (Math.abs(dot) > 0.999) {\n elbowDirection = undefined;\n }\n }\n return elbowDirection;\n}\n\n/**\n * Computes the attachment point for a leader line on a text annotation frame.\n *\n * The attachment point is determined based on the leader's attachment mode:\n * - `\"Nearest\"`: Finds the closest point on the frame curve to the leader's start point.\n * - `\"KeyPoint\"`: Uses a specific curve segment and fraction along that segment to determine the point.\n * - `\"TextPoint\"`: Calculates a point on the text layout (top/bottom, left/right) and projects it onto the frame curve.\n *\n * @param leader - The leader props.\n * @param frameCurve - The curve (Loop or Path) representing the annotation frame.\n * @param textLayout - The layout information for the text block.\n * @param transform - The transform applied to the text layout.\n * @returns The computed attachment point as a `Point3d`, or `undefined` if it cannot be determined.\n * @beta\n */\nexport function computeLeaderAttachmentPoint(\n leader: TextAnnotationLeader,\n frameCurve: Loop | Path,\n textLayout: TextBlockLayout,\n transform: Transform\n): Point3d | undefined {\n let attachmentPoint: Point3d | undefined;\n\n if (leader.attachment.mode === \"Nearest\") {\n attachmentPoint = frameCurve.closestPoint(leader.startPoint)?.point;\n } else if (leader.attachment.mode === \"KeyPoint\") {\n const curves = frameCurve.collectCurvePrimitives(undefined, false, true);\n const curveIndex = leader.attachment.curveIndex;\n const fraction = leader.attachment.fraction;\n if (curveIndex >= curves.length) {\n // If the curveIndex is invalid, use the last curve\n // This is a fallback to avoid out-of-bounds access\n attachmentPoint = curves[curves.length - 1].fractionToPoint(fraction);\n } else {\n attachmentPoint = curves[curveIndex].fractionToPoint(fraction);\n }\n } else { // attachment.mode=\"TextPoint\"\n let scaleDirection = transform.matrix.getColumn(0).negate(); // direction to draw a scaled line from text attachment point to find intersection point on frame\n let lineIndex: number;\n if (leader.attachment.position.includes(\"Top\")) {\n lineIndex = 0\n } else {\n lineIndex = textLayout.lines.length - 1\n }\n const lineRange = textLayout.lines[lineIndex].range;\n const lineOffset = textLayout.lines[lineIndex].offsetFromDocument;\n const origin = transform.multiplyPoint3d(Point3d.fromJSON(lineOffset));\n let attachmentPointOnText = origin.plusScaled(transform.matrix.getColumn(1), ((lineRange.yLength()) / 2));\n\n if (leader.attachment.position.includes(\"Right\")) {\n attachmentPointOnText = attachmentPointOnText.plusScaled(transform.matrix.getColumn(0), lineRange.xLength());\n scaleDirection = scaleDirection.negate();\n }\n // Find the nearest intersection point on the frame to get the correct attachment point\n // Extend the direction vector to create a target point far along the direction\n const targetPoint = attachmentPointOnText.plusScaled(scaleDirection, 1e6); // Scale the direction vector to a large value\n const intersectionLine = LineSegment3d.create(attachmentPointOnText, targetPoint);\n const closestPointDetail = CurveCurve.intersectionXYZPairs(intersectionLine, false, frameCurve, false);\n attachmentPoint = closestPointDetail[0]?.detailA.point;\n }\n return attachmentPoint;\n}"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Elements
|
|
3
3
|
*/
|
|
4
|
-
import { TextAnnotation, TextAnnotation2dProps, TextAnnotation3dProps } from "@itwin/core-common";
|
|
4
|
+
import { AnnotationTextStyleProps, Code, CodeProps, CodeScopeProps, EntityReferenceSet, Placement2dProps, Placement3dProps, TextAnnotation, TextAnnotation2dProps, TextAnnotation3dProps, TextAnnotationProps, TextStyleSettings, TextStyleSettingsProps } from "@itwin/core-common";
|
|
5
5
|
import { IModelDb } from "../IModelDb";
|
|
6
|
-
import { AnnotationElement2d, GraphicalElement3d } from "../Element";
|
|
6
|
+
import { AnnotationElement2d, DefinitionElement, GraphicalElement3d, OnElementPropsArg } from "../Element";
|
|
7
|
+
import { Id64String } from "@itwin/core-bentley";
|
|
7
8
|
/** An element that displays textual content within a 2d model.
|
|
8
9
|
* The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.
|
|
9
10
|
* @see [[setAnnotation]] to change the textual content.
|
|
@@ -12,18 +13,58 @@ import { AnnotationElement2d, GraphicalElement3d } from "../Element";
|
|
|
12
13
|
export declare class TextAnnotation2d extends AnnotationElement2d {
|
|
13
14
|
/** @internal */
|
|
14
15
|
static get className(): string;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
toJSON(): TextAnnotation2dProps;
|
|
16
|
+
/** Optional string containing the data associated with the text annotation. */
|
|
17
|
+
private _textAnnotationData?;
|
|
18
18
|
/** Extract the textual content, if present.
|
|
19
19
|
* @see [[setAnnotation]] to change it.
|
|
20
20
|
*/
|
|
21
21
|
getAnnotation(): TextAnnotation | undefined;
|
|
22
|
-
/** Change the textual content
|
|
22
|
+
/** Change the textual content of the `TextAnnotation2d`.
|
|
23
23
|
* @see [[getAnnotation]] to extract the current annotation.
|
|
24
24
|
* @param annotation The new annotation
|
|
25
25
|
*/
|
|
26
26
|
setAnnotation(annotation: TextAnnotation): void;
|
|
27
|
+
protected constructor(props: TextAnnotation2dProps, iModel: IModelDb);
|
|
28
|
+
/** Creates a new instance of `TextAnnotation2d` from its JSON representation. */
|
|
29
|
+
static fromJSON(props: TextAnnotation2dProps, iModel: IModelDb): TextAnnotation2d;
|
|
30
|
+
/**
|
|
31
|
+
* Converts the current `TextAnnotation2d` instance to its JSON representation.
|
|
32
|
+
* It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.
|
|
33
|
+
|
|
34
|
+
* @inheritdoc
|
|
35
|
+
*/
|
|
36
|
+
toJSON(): TextAnnotation2dProps;
|
|
37
|
+
/** Creates a new `TextAnnotation2d` instance with the specified properties.
|
|
38
|
+
* @param iModelDb The iModel.
|
|
39
|
+
* @param category The category ID for the annotation.
|
|
40
|
+
* @param model The model ID where the annotation will be placed.
|
|
41
|
+
* @param placement The placement properties for the annotation.
|
|
42
|
+
* @param textAnnotationData Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation2d`. Essentially an empty element if not provided.
|
|
43
|
+
* @param code Optional code for the element.
|
|
44
|
+
*/
|
|
45
|
+
static create(iModelDb: IModelDb, category: Id64String, model: Id64String, placement: Placement2dProps, textAnnotationData?: TextAnnotationProps, code?: CodeProps): TextAnnotation2d;
|
|
46
|
+
/**
|
|
47
|
+
* Updates the geometry of the TextAnnotation2d on insert.
|
|
48
|
+
* @inheritdoc
|
|
49
|
+
* @beta
|
|
50
|
+
*/
|
|
51
|
+
protected static onInsert(arg: OnElementPropsArg): void;
|
|
52
|
+
/**
|
|
53
|
+
* Updates the geometry of the TextAnnotation2d on update.
|
|
54
|
+
* @inheritdoc
|
|
55
|
+
* @beta
|
|
56
|
+
*/
|
|
57
|
+
protected static onUpdate(arg: OnElementPropsArg): void;
|
|
58
|
+
/**
|
|
59
|
+
* Populates the `elementGeometryBuilderParams` property in the [TextAnnotation2dProps]($common).
|
|
60
|
+
* It only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.
|
|
61
|
+
*/
|
|
62
|
+
protected static updateGeometry(iModelDb: IModelDb, props: TextAnnotation2dProps): void;
|
|
63
|
+
/**
|
|
64
|
+
* Collects reference IDs used by this `TextAnnotation2d`.
|
|
65
|
+
* @inheritdoc
|
|
66
|
+
*/
|
|
67
|
+
protected collectReferenceIds(ids: EntityReferenceSet): void;
|
|
27
68
|
}
|
|
28
69
|
/** An element that displays textual content within a 3d model.
|
|
29
70
|
* The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.
|
|
@@ -33,17 +74,114 @@ export declare class TextAnnotation2d extends AnnotationElement2d {
|
|
|
33
74
|
export declare class TextAnnotation3d extends GraphicalElement3d {
|
|
34
75
|
/** @internal */
|
|
35
76
|
static get className(): string;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
toJSON(): TextAnnotation3dProps;
|
|
77
|
+
/** Optional string containing the data associated with the text annotation. */
|
|
78
|
+
private _textAnnotationData?;
|
|
39
79
|
/** Extract the textual content, if present.
|
|
40
80
|
* @see [[setAnnotation]] to change it.
|
|
41
81
|
*/
|
|
42
82
|
getAnnotation(): TextAnnotation | undefined;
|
|
43
|
-
/** Change the textual content
|
|
83
|
+
/** Change the textual content of the `TextAnnotation3d`.
|
|
44
84
|
* @see [[getAnnotation]] to extract the current annotation.
|
|
45
85
|
* @param annotation The new annotation
|
|
46
86
|
*/
|
|
47
87
|
setAnnotation(annotation: TextAnnotation): void;
|
|
88
|
+
protected constructor(props: TextAnnotation3dProps, iModel: IModelDb);
|
|
89
|
+
/** Creates a new instance of `TextAnnotation3d` from its JSON representation. */
|
|
90
|
+
static fromJSON(props: TextAnnotation3dProps, iModel: IModelDb): TextAnnotation3d;
|
|
91
|
+
/**
|
|
92
|
+
* Converts the current `TextAnnotation3d` instance to its JSON representation.
|
|
93
|
+
* It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.
|
|
94
|
+
* @inheritdoc
|
|
95
|
+
*/
|
|
96
|
+
toJSON(): TextAnnotation3dProps;
|
|
97
|
+
/** Creates a new `TextAnnotation3d` instance with the specified properties.
|
|
98
|
+
* @param iModelDb The iModel.
|
|
99
|
+
* @param category The category ID for the annotation.
|
|
100
|
+
* @param model The model ID where the annotation will be placed.
|
|
101
|
+
* @param placement The placement properties for the annotation.
|
|
102
|
+
* @param textAnnotationData Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation3d`. Essentially an empty element if not provided.
|
|
103
|
+
* @param code Optional code for the element.
|
|
104
|
+
*/
|
|
105
|
+
static create(iModelDb: IModelDb, category: Id64String, model: Id64String, placement: Placement3dProps, textAnnotationData?: TextAnnotationProps, code?: CodeProps): TextAnnotation3d;
|
|
106
|
+
/**
|
|
107
|
+
* Updates the geometry of the TextAnnotation3d on insert.
|
|
108
|
+
* @inheritdoc
|
|
109
|
+
* @beta
|
|
110
|
+
*/
|
|
111
|
+
protected static onInsert(arg: OnElementPropsArg): void;
|
|
112
|
+
/**
|
|
113
|
+
* Updates the geometry of the TextAnnotation3d on update.
|
|
114
|
+
* @inheritdoc
|
|
115
|
+
* @beta
|
|
116
|
+
*/
|
|
117
|
+
protected static onUpdate(arg: OnElementPropsArg): void;
|
|
118
|
+
/**
|
|
119
|
+
* Populates the `elementGeometryBuilderParams` property in the [TextAnnotation3dProps]($common).
|
|
120
|
+
* It only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.
|
|
121
|
+
*/
|
|
122
|
+
protected static updateGeometry(iModelDb: IModelDb, props: TextAnnotation3dProps): void;
|
|
123
|
+
/**
|
|
124
|
+
* Collects reference IDs used by this `TextAnnotation3d`.
|
|
125
|
+
* @inheritdoc
|
|
126
|
+
*/
|
|
127
|
+
protected collectReferenceIds(ids: EntityReferenceSet): void;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The definition element that holds text style information.
|
|
131
|
+
* The style is stored as a [TextStyleSettings]($common).
|
|
132
|
+
* @beta
|
|
133
|
+
*/
|
|
134
|
+
export declare class AnnotationTextStyle extends DefinitionElement {
|
|
135
|
+
/** @internal */
|
|
136
|
+
static get className(): string;
|
|
137
|
+
/**
|
|
138
|
+
* Optional text describing the `AnnotationTextStyle`.
|
|
139
|
+
*/
|
|
140
|
+
description?: string;
|
|
141
|
+
/**
|
|
142
|
+
* The text style settings for the `AnnotationTextStyle`.
|
|
143
|
+
* @see [[TextStyleSettings]] for more information.
|
|
144
|
+
*/
|
|
145
|
+
settings: TextStyleSettings;
|
|
146
|
+
protected constructor(props: AnnotationTextStyleProps, iModel: IModelDb);
|
|
147
|
+
/**
|
|
148
|
+
* Creates a Code for an `AnnotationTextStyle` given a name that is meant to be unique within the scope of the specified DefinitionModel.
|
|
149
|
+
*
|
|
150
|
+
* @param iModel - The IModelDb.
|
|
151
|
+
* @param definitionModelId - The ID of the DefinitionModel that contains the AnnotationTextStyle and provides the scope for its name.
|
|
152
|
+
* @param name - The AnnotationTextStyle name.
|
|
153
|
+
*/
|
|
154
|
+
static createCode(iModel: IModelDb, definitionModelId: CodeScopeProps, name: string): Code;
|
|
155
|
+
/**
|
|
156
|
+
* Creates a new instance of `AnnotationTextStyle` with the specified properties.
|
|
157
|
+
*
|
|
158
|
+
* @param iModelDb - The iModelDb.
|
|
159
|
+
* @param definitionModelId - The ID of the [[DefinitionModel]].
|
|
160
|
+
* @param name - The name to assign to the `AnnotationTextStyle`.
|
|
161
|
+
* @param settings - Optional text style settings used to create the `AnnotationTextStyle`. Default settings will be used if not provided.
|
|
162
|
+
* @param description - Optional description for the `AnnotationTextStyle`.
|
|
163
|
+
*/
|
|
164
|
+
static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string, settings?: TextStyleSettingsProps, description?: string): AnnotationTextStyle;
|
|
165
|
+
/**
|
|
166
|
+
* Converts the current `AnnotationTextStyle` instance to its JSON representation.
|
|
167
|
+
* @inheritdoc
|
|
168
|
+
*/
|
|
169
|
+
toJSON(): AnnotationTextStyleProps;
|
|
170
|
+
/** Creates a new instance of `AnnotationTextStyle` from its JSON representation. */
|
|
171
|
+
static fromJSON(props: AnnotationTextStyleProps, iModel: IModelDb): AnnotationTextStyle;
|
|
172
|
+
/**
|
|
173
|
+
* Validates that the AnnotationTextStyle's settings are valid before insert.
|
|
174
|
+
* @inheritdoc
|
|
175
|
+
* @beta
|
|
176
|
+
*/
|
|
177
|
+
protected static onInsert(arg: OnElementPropsArg): void;
|
|
178
|
+
/**
|
|
179
|
+
* Validates that the AnnotationTextStyle's settings are valid before update.
|
|
180
|
+
* @inheritdoc
|
|
181
|
+
* @beta
|
|
182
|
+
*/
|
|
183
|
+
protected static onUpdate(arg: OnElementPropsArg): void;
|
|
184
|
+
private static validateSettings;
|
|
185
|
+
private static parseTextStyleSettings;
|
|
48
186
|
}
|
|
49
187
|
//# sourceMappingURL=TextAnnotationElement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextAnnotationElement.d.ts","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationElement.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,
|
|
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,EAA2D,kBAAkB,EAAe,gBAAgB,EAAe,gBAAgB,EAAkB,cAAc,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACrY,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC3G,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAwBjD;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,mBAAmB;IACvD,gBAAgB;IAChB,WAA2B,SAAS,IAAI,MAAM,CAA+B;IAC7E,+EAA+E;IAC/E,OA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,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,OAAO,CAAC,MAAM,CAAC,sBAAsB;CAQtC"}
|
|
@@ -7,16 +7,28 @@
|
|
|
7
7
|
* @module Elements
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.TextAnnotation3d = exports.TextAnnotation2d = void 0;
|
|
10
|
+
exports.AnnotationTextStyle = exports.TextAnnotation3d = exports.TextAnnotation2d = void 0;
|
|
11
11
|
const core_common_1 = require("@itwin/core-common");
|
|
12
12
|
const Element_1 = require("../Element");
|
|
13
13
|
const TextBlockLayout_1 = require("./TextBlockLayout");
|
|
14
14
|
const TextAnnotationGeometry_1 = require("./TextAnnotationGeometry");
|
|
15
|
-
function
|
|
15
|
+
function parseTextAnnotationData(json) {
|
|
16
|
+
if (!json)
|
|
17
|
+
return undefined;
|
|
18
|
+
try {
|
|
19
|
+
return JSON.parse(json);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function getElementGeometryBuilderParams(iModel, modelId, _placementProps, stringifiedAnnotationProps, categoryId, _subCategory) {
|
|
26
|
+
const annotationProps = parseTextAnnotationData(stringifiedAnnotationProps);
|
|
16
27
|
const textBlock = core_common_1.TextAnnotation.fromJSON(annotationProps).textBlock;
|
|
17
|
-
const
|
|
28
|
+
const textStyleResolver = new TextBlockLayout_1.TextStyleResolver({ textBlock, iModel, modelId });
|
|
29
|
+
const layout = (0, TextBlockLayout_1.layoutTextBlock)({ iModel, textBlock, textStyleResolver });
|
|
18
30
|
const builder = new core_common_1.ElementGeometry.Builder();
|
|
19
|
-
(0, TextAnnotationGeometry_1.appendTextAnnotationGeometry)({ layout, annotationProps, builder, categoryId });
|
|
31
|
+
(0, TextAnnotationGeometry_1.appendTextAnnotationGeometry)({ layout, textStyleResolver, annotationProps: annotationProps ?? {}, builder, categoryId });
|
|
20
32
|
return { entryArray: builder.entries };
|
|
21
33
|
}
|
|
22
34
|
/** An element that displays textual content within a 2d model.
|
|
@@ -27,28 +39,103 @@ function getElementGeometryBuilderParams(iModel, _placementProps, annotationProp
|
|
|
27
39
|
class TextAnnotation2d extends Element_1.AnnotationElement2d {
|
|
28
40
|
/** @internal */
|
|
29
41
|
static get className() { return "TextAnnotation2d"; }
|
|
30
|
-
|
|
42
|
+
/** Optional string containing the data associated with the text annotation. */
|
|
43
|
+
_textAnnotationData;
|
|
44
|
+
/** Extract the textual content, if present.
|
|
45
|
+
* @see [[setAnnotation]] to change it.
|
|
46
|
+
*/
|
|
47
|
+
getAnnotation() {
|
|
48
|
+
const textAnnotationProps = parseTextAnnotationData(this._textAnnotationData);
|
|
49
|
+
return textAnnotationProps ? core_common_1.TextAnnotation.fromJSON(textAnnotationProps) : undefined;
|
|
50
|
+
}
|
|
51
|
+
/** Change the textual content of the `TextAnnotation2d`.
|
|
52
|
+
* @see [[getAnnotation]] to extract the current annotation.
|
|
53
|
+
* @param annotation The new annotation
|
|
54
|
+
*/
|
|
55
|
+
setAnnotation(annotation) {
|
|
56
|
+
this._textAnnotationData = annotation ? JSON.stringify(annotation.toJSON()) : undefined;
|
|
57
|
+
}
|
|
58
|
+
constructor(props, iModel) {
|
|
59
|
+
super(props, iModel);
|
|
60
|
+
this._textAnnotationData = props.textAnnotationData;
|
|
61
|
+
}
|
|
62
|
+
/** Creates a new instance of `TextAnnotation2d` from its JSON representation. */
|
|
31
63
|
static fromJSON(props, iModel) {
|
|
32
64
|
return new TextAnnotation2d(props, iModel);
|
|
33
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Converts the current `TextAnnotation2d` instance to its JSON representation.
|
|
68
|
+
* It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.
|
|
69
|
+
|
|
70
|
+
* @inheritdoc
|
|
71
|
+
*/
|
|
34
72
|
toJSON() {
|
|
35
73
|
const props = super.toJSON();
|
|
36
|
-
props.
|
|
74
|
+
props.textAnnotationData = this._textAnnotationData;
|
|
75
|
+
if (this._textAnnotationData) {
|
|
76
|
+
props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.placement, this._textAnnotationData, this.category);
|
|
77
|
+
}
|
|
37
78
|
return props;
|
|
38
79
|
}
|
|
39
|
-
/**
|
|
40
|
-
* @
|
|
80
|
+
/** Creates a new `TextAnnotation2d` instance with the specified properties.
|
|
81
|
+
* @param iModelDb The iModel.
|
|
82
|
+
* @param category The category ID for the annotation.
|
|
83
|
+
* @param model The model ID where the annotation will be placed.
|
|
84
|
+
* @param placement The placement properties for the annotation.
|
|
85
|
+
* @param textAnnotationData Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation2d`. Essentially an empty element if not provided.
|
|
86
|
+
* @param code Optional code for the element.
|
|
41
87
|
*/
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
88
|
+
static create(iModelDb, category, model, placement, textAnnotationData, code) {
|
|
89
|
+
const props = {
|
|
90
|
+
classFullName: this.classFullName,
|
|
91
|
+
textAnnotationData: JSON.stringify(textAnnotationData),
|
|
92
|
+
placement,
|
|
93
|
+
model,
|
|
94
|
+
category,
|
|
95
|
+
code: code ?? core_common_1.Code.createEmpty(),
|
|
96
|
+
};
|
|
97
|
+
return new this(props, iModelDb);
|
|
45
98
|
}
|
|
46
|
-
/**
|
|
47
|
-
*
|
|
48
|
-
* @
|
|
99
|
+
/**
|
|
100
|
+
* Updates the geometry of the TextAnnotation2d on insert.
|
|
101
|
+
* @inheritdoc
|
|
102
|
+
* @beta
|
|
49
103
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
104
|
+
static onInsert(arg) {
|
|
105
|
+
super.onInsert(arg);
|
|
106
|
+
this.updateGeometry(arg.iModel, arg.props);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Updates the geometry of the TextAnnotation2d on update.
|
|
110
|
+
* @inheritdoc
|
|
111
|
+
* @beta
|
|
112
|
+
*/
|
|
113
|
+
static onUpdate(arg) {
|
|
114
|
+
super.onUpdate(arg);
|
|
115
|
+
this.updateGeometry(arg.iModel, arg.props);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Populates the `elementGeometryBuilderParams` property in the [TextAnnotation2dProps]($common).
|
|
119
|
+
* It only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.
|
|
120
|
+
*/
|
|
121
|
+
static updateGeometry(iModelDb, props) {
|
|
122
|
+
if (props.elementGeometryBuilderParams || !props.textAnnotationData) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
props.elementGeometryBuilderParams = getElementGeometryBuilderParams(iModelDb, props.model, props.placement ?? core_common_1.Placement2d.fromJSON(), props.textAnnotationData, props.category);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Collects reference IDs used by this `TextAnnotation2d`.
|
|
129
|
+
* @inheritdoc
|
|
130
|
+
*/
|
|
131
|
+
collectReferenceIds(ids) {
|
|
132
|
+
super.collectReferenceIds(ids);
|
|
133
|
+
const annotation = this.getAnnotation();
|
|
134
|
+
if (!annotation) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (annotation.textBlock.styleId)
|
|
138
|
+
ids.addElement(annotation.textBlock.styleId);
|
|
52
139
|
}
|
|
53
140
|
}
|
|
54
141
|
exports.TextAnnotation2d = TextAnnotation2d;
|
|
@@ -60,29 +147,210 @@ exports.TextAnnotation2d = TextAnnotation2d;
|
|
|
60
147
|
class TextAnnotation3d extends Element_1.GraphicalElement3d {
|
|
61
148
|
/** @internal */
|
|
62
149
|
static get className() { return "TextAnnotation3d"; }
|
|
63
|
-
|
|
150
|
+
/** Optional string containing the data associated with the text annotation. */
|
|
151
|
+
_textAnnotationData;
|
|
152
|
+
/** Extract the textual content, if present.
|
|
153
|
+
* @see [[setAnnotation]] to change it.
|
|
154
|
+
*/
|
|
155
|
+
getAnnotation() {
|
|
156
|
+
const textAnnotationProps = parseTextAnnotationData(this._textAnnotationData);
|
|
157
|
+
return textAnnotationProps ? core_common_1.TextAnnotation.fromJSON(textAnnotationProps) : undefined;
|
|
158
|
+
}
|
|
159
|
+
/** Change the textual content of the `TextAnnotation3d`.
|
|
160
|
+
* @see [[getAnnotation]] to extract the current annotation.
|
|
161
|
+
* @param annotation The new annotation
|
|
162
|
+
*/
|
|
163
|
+
setAnnotation(annotation) {
|
|
164
|
+
this._textAnnotationData = annotation ? JSON.stringify(annotation.toJSON()) : undefined;
|
|
165
|
+
}
|
|
166
|
+
constructor(props, iModel) {
|
|
167
|
+
super(props, iModel);
|
|
168
|
+
this._textAnnotationData = props.textAnnotationData;
|
|
169
|
+
}
|
|
170
|
+
/** Creates a new instance of `TextAnnotation3d` from its JSON representation. */
|
|
64
171
|
static fromJSON(props, iModel) {
|
|
65
172
|
return new TextAnnotation3d(props, iModel);
|
|
66
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Converts the current `TextAnnotation3d` instance to its JSON representation.
|
|
176
|
+
* It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.
|
|
177
|
+
* @inheritdoc
|
|
178
|
+
*/
|
|
67
179
|
toJSON() {
|
|
68
180
|
const props = super.toJSON();
|
|
69
|
-
props.
|
|
181
|
+
props.textAnnotationData = this._textAnnotationData;
|
|
182
|
+
if (this._textAnnotationData) {
|
|
183
|
+
props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.placement, this._textAnnotationData, this.category);
|
|
184
|
+
}
|
|
70
185
|
return props;
|
|
71
186
|
}
|
|
72
|
-
/**
|
|
73
|
-
* @
|
|
187
|
+
/** Creates a new `TextAnnotation3d` instance with the specified properties.
|
|
188
|
+
* @param iModelDb The iModel.
|
|
189
|
+
* @param category The category ID for the annotation.
|
|
190
|
+
* @param model The model ID where the annotation will be placed.
|
|
191
|
+
* @param placement The placement properties for the annotation.
|
|
192
|
+
* @param textAnnotationData Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation3d`. Essentially an empty element if not provided.
|
|
193
|
+
* @param code Optional code for the element.
|
|
74
194
|
*/
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
195
|
+
static create(iModelDb, category, model, placement, textAnnotationData, code) {
|
|
196
|
+
const props = {
|
|
197
|
+
classFullName: this.classFullName,
|
|
198
|
+
textAnnotationData: JSON.stringify(textAnnotationData),
|
|
199
|
+
placement,
|
|
200
|
+
model,
|
|
201
|
+
category,
|
|
202
|
+
code: code ?? core_common_1.Code.createEmpty(),
|
|
203
|
+
};
|
|
204
|
+
return new this(props, iModelDb);
|
|
78
205
|
}
|
|
79
|
-
/**
|
|
80
|
-
*
|
|
81
|
-
* @
|
|
206
|
+
/**
|
|
207
|
+
* Updates the geometry of the TextAnnotation3d on insert.
|
|
208
|
+
* @inheritdoc
|
|
209
|
+
* @beta
|
|
82
210
|
*/
|
|
83
|
-
|
|
84
|
-
|
|
211
|
+
static onInsert(arg) {
|
|
212
|
+
super.onInsert(arg);
|
|
213
|
+
this.updateGeometry(arg.iModel, arg.props);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Updates the geometry of the TextAnnotation3d on update.
|
|
217
|
+
* @inheritdoc
|
|
218
|
+
* @beta
|
|
219
|
+
*/
|
|
220
|
+
static onUpdate(arg) {
|
|
221
|
+
super.onUpdate(arg);
|
|
222
|
+
this.updateGeometry(arg.iModel, arg.props);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Populates the `elementGeometryBuilderParams` property in the [TextAnnotation3dProps]($common).
|
|
226
|
+
* It only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.
|
|
227
|
+
*/
|
|
228
|
+
static updateGeometry(iModelDb, props) {
|
|
229
|
+
if (props.elementGeometryBuilderParams || !props.textAnnotationData) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
props.elementGeometryBuilderParams = getElementGeometryBuilderParams(iModelDb, props.model, props.placement ?? core_common_1.Placement3d.fromJSON(), props.textAnnotationData, props.category);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Collects reference IDs used by this `TextAnnotation3d`.
|
|
236
|
+
* @inheritdoc
|
|
237
|
+
*/
|
|
238
|
+
collectReferenceIds(ids) {
|
|
239
|
+
super.collectReferenceIds(ids);
|
|
240
|
+
const annotation = this.getAnnotation();
|
|
241
|
+
if (!annotation) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (annotation.textBlock.styleId)
|
|
245
|
+
ids.addElement(annotation.textBlock.styleId);
|
|
85
246
|
}
|
|
86
247
|
}
|
|
87
248
|
exports.TextAnnotation3d = TextAnnotation3d;
|
|
249
|
+
/**
|
|
250
|
+
* The definition element that holds text style information.
|
|
251
|
+
* The style is stored as a [TextStyleSettings]($common).
|
|
252
|
+
* @beta
|
|
253
|
+
*/
|
|
254
|
+
class AnnotationTextStyle extends Element_1.DefinitionElement {
|
|
255
|
+
/** @internal */
|
|
256
|
+
static get className() { return "AnnotationTextStyle"; }
|
|
257
|
+
/**
|
|
258
|
+
* Optional text describing the `AnnotationTextStyle`.
|
|
259
|
+
*/
|
|
260
|
+
description;
|
|
261
|
+
/**
|
|
262
|
+
* The text style settings for the `AnnotationTextStyle`.
|
|
263
|
+
* @see [[TextStyleSettings]] for more information.
|
|
264
|
+
*/
|
|
265
|
+
settings;
|
|
266
|
+
constructor(props, iModel) {
|
|
267
|
+
super(props, iModel);
|
|
268
|
+
this.description = props.description;
|
|
269
|
+
const settingsProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);
|
|
270
|
+
this.settings = core_common_1.TextStyleSettings.fromJSON(settingsProps);
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Creates a Code for an `AnnotationTextStyle` given a name that is meant to be unique within the scope of the specified DefinitionModel.
|
|
274
|
+
*
|
|
275
|
+
* @param iModel - The IModelDb.
|
|
276
|
+
* @param definitionModelId - The ID of the DefinitionModel that contains the AnnotationTextStyle and provides the scope for its name.
|
|
277
|
+
* @param name - The AnnotationTextStyle name.
|
|
278
|
+
*/
|
|
279
|
+
static createCode(iModel, definitionModelId, name) {
|
|
280
|
+
const codeSpec = iModel.codeSpecs.getByName(core_common_1.BisCodeSpec.annotationTextStyle);
|
|
281
|
+
return new core_common_1.Code({ spec: codeSpec.id, scope: definitionModelId, value: name });
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Creates a new instance of `AnnotationTextStyle` with the specified properties.
|
|
285
|
+
*
|
|
286
|
+
* @param iModelDb - The iModelDb.
|
|
287
|
+
* @param definitionModelId - The ID of the [[DefinitionModel]].
|
|
288
|
+
* @param name - The name to assign to the `AnnotationTextStyle`.
|
|
289
|
+
* @param settings - Optional text style settings used to create the `AnnotationTextStyle`. Default settings will be used if not provided.
|
|
290
|
+
* @param description - Optional description for the `AnnotationTextStyle`.
|
|
291
|
+
*/
|
|
292
|
+
static create(iModelDb, definitionModelId, name, settings, description) {
|
|
293
|
+
const props = {
|
|
294
|
+
classFullName: this.classFullName,
|
|
295
|
+
model: definitionModelId,
|
|
296
|
+
code: this.createCode(iModelDb, definitionModelId, name).toJSON(),
|
|
297
|
+
description,
|
|
298
|
+
settings: JSON.stringify(settings),
|
|
299
|
+
};
|
|
300
|
+
return new this(props, iModelDb);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Converts the current `AnnotationTextStyle` instance to its JSON representation.
|
|
304
|
+
* @inheritdoc
|
|
305
|
+
*/
|
|
306
|
+
toJSON() {
|
|
307
|
+
const props = super.toJSON();
|
|
308
|
+
props.description = this.description;
|
|
309
|
+
props.settings = JSON.stringify(this.settings.toJSON());
|
|
310
|
+
return props;
|
|
311
|
+
}
|
|
312
|
+
/** Creates a new instance of `AnnotationTextStyle` from its JSON representation. */
|
|
313
|
+
static fromJSON(props, iModel) {
|
|
314
|
+
return new AnnotationTextStyle(props, iModel);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Validates that the AnnotationTextStyle's settings are valid before insert.
|
|
318
|
+
* @inheritdoc
|
|
319
|
+
* @beta
|
|
320
|
+
*/
|
|
321
|
+
static onInsert(arg) {
|
|
322
|
+
super.onInsert(arg);
|
|
323
|
+
this.validateSettings(arg.props);
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Validates that the AnnotationTextStyle's settings are valid before update.
|
|
327
|
+
* @inheritdoc
|
|
328
|
+
* @beta
|
|
329
|
+
*/
|
|
330
|
+
static onUpdate(arg) {
|
|
331
|
+
super.onUpdate(arg);
|
|
332
|
+
this.validateSettings(arg.props);
|
|
333
|
+
}
|
|
334
|
+
static validateSettings(props) {
|
|
335
|
+
const settingProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);
|
|
336
|
+
if (!settingProps)
|
|
337
|
+
return;
|
|
338
|
+
const settings = core_common_1.TextStyleSettings.fromJSON(settingProps);
|
|
339
|
+
const errors = settings.getValidationErrors();
|
|
340
|
+
if (errors.length > 0) {
|
|
341
|
+
throw new Error(`Invalid AnnotationTextStyle settings: ${errors.join(", ")}`);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
static parseTextStyleSettings(json) {
|
|
345
|
+
if (!json)
|
|
346
|
+
return undefined;
|
|
347
|
+
try {
|
|
348
|
+
return JSON.parse(json);
|
|
349
|
+
}
|
|
350
|
+
catch {
|
|
351
|
+
return undefined;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
exports.AnnotationTextStyle = AnnotationTextStyle;
|
|
88
356
|
//# sourceMappingURL=TextAnnotationElement.js.map
|