@itwin/core-backend 4.8.0-dev.4 → 4.8.0-dev.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
# Change Log - @itwin/core-backend
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 12 Jun 2024 18:03:49 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 4.7.0
|
|
6
|
+
Wed, 12 Jun 2024 18:02:16 GMT
|
|
7
|
+
|
|
8
|
+
### Updates
|
|
9
|
+
|
|
10
|
+
- schemaUpgrade() now push change to schema sync
|
|
11
|
+
- Remove @alpha BackendLoggerCategory.Editing
|
|
12
|
+
- Added getAvailableCoordinateReferenceSystems.
|
|
13
|
+
- Brotli compression enabled for RPC requests.
|
|
14
|
+
- Increase restrictions on native app storage name.
|
|
15
|
+
- Added computeTextBlockExtents
|
|
4
16
|
|
|
5
17
|
## 4.6.2
|
|
6
18
|
Sat, 08 Jun 2024 00:50:25 GMT
|
|
@@ -23,7 +23,7 @@ export interface ProduceTextAnnotationGeometryArgs {
|
|
|
23
23
|
/** @internal chiefly for tests */
|
|
24
24
|
findFontId?: FindFontId;
|
|
25
25
|
}
|
|
26
|
-
/** Produce a geometric representation of a text annotation.
|
|
26
|
+
/** Produce a geometric representation of a text annotation, with the annotation's anchor point at the origin.
|
|
27
27
|
* The result can be supplied to [GeometryStreamBuilder.appendTextBlock]($common).
|
|
28
28
|
* @see [[TextAnnotation2d.setAnnotation]] and [[TextAnnotation3d.setAnnotation]] to update the annotation, geometry, and placement of an annotation element.
|
|
29
29
|
* @beta
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextAnnotationGeometry.d.ts","sourceRoot":"","sources":["../../src/TextAnnotationGeometry.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAY,cAAc,EAAE,sBAAsB,EAA2D,MAAM,oBAAoB,CAAC;AAC/I,OAAO,EAAE,0BAA0B,EAAE,UAAU,EAAE,aAAa,EAA+C,MAAM,wBAAwB,CAAC;AAG5I,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"TextAnnotationGeometry.d.ts","sourceRoot":"","sources":["../../src/TextAnnotationGeometry.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAY,cAAc,EAAE,sBAAsB,EAA2D,MAAM,oBAAoB,CAAC;AAC/I,OAAO,EAAE,0BAA0B,EAAE,UAAU,EAAE,aAAa,EAA+C,MAAM,wBAAwB,CAAC;AAG5I,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAmKtC;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD,yDAAyD;IACzD,UAAU,EAAE,cAAc,CAAC;IAC3B,6DAA6D;IAC7D,MAAM,EAAE,QAAQ,CAAC;IACjB;;OAEG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,kCAAkC;IAClC,gBAAgB,CAAC,EAAE,0BAA0B,CAAC;IAC9C,kCAAkC;IAClC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,kCAAkC;IAClC,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,iCAAiC,GAAG,sBAAsB,CAW7G"}
|
|
@@ -120,22 +120,26 @@ function produceTextBlockGeometry(layout, documentTransform, debugAnchorPt) {
|
|
|
120
120
|
context.entries.push({
|
|
121
121
|
color: core_common_1.ColorDef.red.toJSON(),
|
|
122
122
|
});
|
|
123
|
+
const lx = layout.range.low.x - debugAnchorPt.x;
|
|
124
|
+
const ly = layout.range.low.y - debugAnchorPt.y;
|
|
125
|
+
const hx = layout.range.high.x - debugAnchorPt.x;
|
|
126
|
+
const hy = layout.range.high.y - debugAnchorPt.y;
|
|
123
127
|
context.entries.push({
|
|
124
128
|
separator: {
|
|
125
|
-
startPoint: [
|
|
126
|
-
endPoint: [
|
|
129
|
+
startPoint: [lx, 0, 0],
|
|
130
|
+
endPoint: [hx, 0, 0],
|
|
127
131
|
},
|
|
128
132
|
});
|
|
129
133
|
context.entries.push({
|
|
130
134
|
separator: {
|
|
131
|
-
startPoint: [
|
|
132
|
-
endPoint: [
|
|
135
|
+
startPoint: [0, ly, 0],
|
|
136
|
+
endPoint: [0, hy, 0],
|
|
133
137
|
},
|
|
134
138
|
});
|
|
135
139
|
}
|
|
136
140
|
return { entries: context.entries };
|
|
137
141
|
}
|
|
138
|
-
/** Produce a geometric representation of a text annotation.
|
|
142
|
+
/** Produce a geometric representation of a text annotation, with the annotation's anchor point at the origin.
|
|
139
143
|
* The result can be supplied to [GeometryStreamBuilder.appendTextBlock]($common).
|
|
140
144
|
* @see [[TextAnnotation2d.setAnnotation]] and [[TextAnnotation3d.setAnnotation]] to update the annotation, geometry, and placement of an annotation element.
|
|
141
145
|
* @beta
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextAnnotationGeometry.js","sourceRoot":"","sources":["../../src/TextAnnotationGeometry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAA+I;AAC/I,iEAA4I;AAC5I,wDAA4F;AAC5F,sDAA6C;AAQ7C,SAAS,QAAQ,CAAC,KAAqB,EAAE,OAAwB;IAC/D,IAAI,KAAK,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC/B,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC;QACzB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAClC,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY,EAAE,GAAc,EAAE,MAAgB;IACtE,IAAA,qBAAM,EAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAExB,MAAM,EAAE,UA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ACpD;SACF,CAAC,CAAC;QACH,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;YACnB,SAAS,EAAE;gBACT,UAAU,EAAE,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;gBACpD,QAAQ,EAAE,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;aACpD;SACF,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;AACtC,CAAC;AAsBD;;;;GAIG;AACH,SAAgB,6BAA6B,CAAC,IAAuC;IACnF,MAAM,MAAM,GAAG,IAAA,sCAAe,EAAC;QAC7B,GAAG,IAAI;QACP,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,SAAS;KACrC,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC;IAChC,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAE/D,MAAM,WAAW,GAAG,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/G,OAAO,wBAAwB,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;AAClE,CAAC;AAXD,sEAWC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ElementGeometry\r\n */\r\n\r\nimport { ColorDef, TextAnnotation, TextBlockGeometryProps, TextBlockGeometryPropsEntry, TextString, TextStyleColor } from \"@itwin/core-common\";\r\nimport { ComputeRangesForTextLayout, FindFontId, FindTextStyle, layoutTextBlock, RunLayout, TextBlockLayout } from \"./TextAnnotationLayout\";\r\nimport { LineSegment3d, Point3d, Range2d, Transform, Vector2d } from \"@itwin/core-geometry\";\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { IModelDb } from \"./IModelDb\";\r\n\r\ninterface GeometryContext {\r\n curColor?: TextStyleColor;\r\n entries: TextBlockGeometryPropsEntry[];\r\n}\r\n\r\nfunction setColor(color: TextStyleColor, context: GeometryContext): void {\r\n if (color !== context.curColor) {\r\n context.curColor = color;\r\n context.entries.push({ color });\r\n }\r\n}\r\n\r\nfunction createTextString(text: string, run: RunLayout, origin?: Point3d): TextString {\r\n assert(text.length > 0);\r\n\r\n const { lineHeight, widthFactor, isBold, isItalic, isUnderlined } = run.style;\r\n\r\n return new TextString({\r\n text,\r\n font: run.fontId,\r\n height: lineHeight,\r\n widthFactor,\r\n bold: isBold,\r\n italic: isItalic,\r\n underline: isUnderlined,\r\n origin,\r\n });\r\n}\r\n\r\nfunction processTextRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\r\n assert(run.source.type === \"text\");\r\n const text = run.source.content.substring(run.charOffset, run.charOffset + run.numChars);\r\n if (text.length === 0) {\r\n return;\r\n }\r\n\r\n const ts = createTextString(text, run);\r\n if (\"none\" !== run.source.baselineShift) {\r\n const isSub = \"subscript\" === run.source.baselineShift;\r\n const offsetFactor = run.style[isSub ? \"subScriptOffsetFactor\" : \"superScriptOffsetFactor\"];\r\n const scale = run.style[isSub ? \"subScriptScale\" : \"superScriptScale\"];\r\n\r\n ts.origin.y += offsetFactor * ts.height;\r\n ts.height *= scale;\r\n }\r\n\r\n ts.transformInPlace(transform);\r\n\r\n setColor(run.style.color, context);\r\n context.entries.push({ text: ts});\r\n}\r\n\r\nfunction createFractionTextString(text: string, run: RunLayout, origin: Point3d, transform: Transform): TextString {\r\n const ts = createTextString(text, run, origin);\r\n assert(undefined !== ts.widthFactor);\r\n\r\n ts.height *= run.style.stackedFractionScale;\r\n\r\n ts.transformInPlace(transform);\r\n\r\n return ts;\r\n}\r\n\r\nfunction processFractionRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\r\n const source = run.source;\r\n assert(source.type === \"fraction\");\r\n\r\n if (source.numerator.length === 0 && source.denominator.length === 0) {\r\n return;\r\n }\r\n\r\n assert(undefined !== run.numeratorRange && undefined !== run.denominatorRange);\r\n\r\n const fontSize = new Vector2d(run.style.lineHeight * run.style.widthFactor, run.style.lineHeight);\r\n fontSize.scale(run.style.stackedFractionScale, fontSize);\r\n\r\n const numeratorOffset = new Point3d(run.numeratorRange.low.x, run.numeratorRange.low.y, 0);\r\n const denominatorOffset = new Point3d(run.denominatorRange.low.x, run.denominatorRange.low.y, 0);\r\n\r\n setColor(run.style.color, context);\r\n\r\n if (source.numerator.length > 0) {\r\n context.entries.push({ text: createFractionTextString(source.numerator, run, numeratorOffset, transform) });\r\n }\r\n\r\n const numeratorRange = Range2d.fromJSON(run.numeratorRange);\r\n const denominatorRange = Range2d.fromJSON(run.denominatorRange);\r\n\r\n let separator: LineSegment3d;\r\n if (run.style.stackedFractionType === \"horizontal\") {\r\n const fractionWidth = Math.max(numeratorRange.xLength(), denominatorRange.xLength());\r\n const y = 1.25 * denominatorRange.yLength();\r\n separator = LineSegment3d.createXYXY(0, y, fractionWidth, y);\r\n } else {\r\n const p0 = new Point3d(denominatorRange.low.x - fontSize.x / 2, denominatorRange.low.y + fontSize.y * (1 / 3), 0);\r\n const p1 = new Point3d(p0.x + fontSize.x, p0.y + fontSize.y * 1.5, 0);\r\n separator = LineSegment3d.createCapture(p0, p1);\r\n }\r\n\r\n separator.tryTransformInPlace(transform);\r\n\r\n context.entries.push({\r\n separator: {\r\n startPoint: separator.point0Ref.toJSON(),\r\n endPoint: separator.point1Ref.toJSON(),\r\n },\r\n });\r\n\r\n if (source.denominator.length > 0) {\r\n context.entries.push({ text: createFractionTextString(source.denominator, run,denominatorOffset, transform) });\r\n }\r\n}\r\n\r\nfunction produceTextBlockGeometry(layout: TextBlockLayout, documentTransform: Transform, debugAnchorPt?: Point3d): TextBlockGeometryProps {\r\n const context: GeometryContext = { entries: [] };\r\n for (const line of layout.lines) {\r\n const lineTrans = Transform.createTranslationXYZ(line.offsetFromDocument.x, line.offsetFromDocument.y, 0);\r\n for (const run of line.runs) {\r\n if (\"linebreak\" === run.source.type) {\r\n continue;\r\n }\r\n\r\n const runTrans = Transform.createTranslationXYZ(run.offsetFromLine.x, run.offsetFromLine.y, 0);\r\n lineTrans.multiplyTransformTransform(runTrans, runTrans);\r\n documentTransform.multiplyTransformTransform(runTrans, runTrans);\r\n if (\"text\" === run.source.type) {\r\n processTextRun(run, runTrans, context);\r\n } else {\r\n processFractionRun(run, runTrans, context);\r\n }\r\n }\r\n }\r\n\r\n if (debugAnchorPt) {\r\n // Draw lines representing the horizontal and vertical ranges, intersecting at the anchor point.\r\n context.entries.push({\r\n color: ColorDef.red.toJSON(),\r\n });\r\n\r\n context.entries.push({\r\n separator: {\r\n startPoint: [layout.range.low.x, debugAnchorPt.y, 0],\r\n endPoint: [layout.range.high.x, debugAnchorPt.y, 0],\r\n },\r\n });\r\n context.entries.push({\r\n separator: {\r\n startPoint: [debugAnchorPt.x, layout.range.low.y, 0],\r\n endPoint: [debugAnchorPt.x, layout.range.high.y, 0],\r\n },\r\n });\r\n }\r\n\r\n return { entries: context.entries };\r\n}\r\n\r\n/** Arguments supplied to [[produceTextAnnotationGeometry]].\r\n * @beta\r\n */\r\nexport interface ProduceTextAnnotationGeometryArgs {\r\n /** The annotation from which to produce the geometry. */\r\n annotation: TextAnnotation;\r\n /** The iModel from which to obtain fonts and text styles. */\r\n iModel: IModelDb;\r\n /** For debugging purposes only, whether to include geometry representing the bounding box and anchor point of the annotation.\r\n * If true, two red lines indicating the horizontal and vertical extents of the bounding box will be included, intersecting at the anchor point.\r\n */\r\n debugAnchorPointAndRange?: boolean;\r\n /** @internal chiefly for tests */\r\n computeTextRange?: ComputeRangesForTextLayout;\r\n /** @internal chiefly for tests */\r\n findTextStyle?: FindTextStyle;\r\n /** @internal chiefly for tests */\r\n findFontId?: FindFontId;\r\n}\r\n\r\n/** Produce a geometric representation of a text annotation.\r\n * The result can be supplied to [GeometryStreamBuilder.appendTextBlock]($common).\r\n * @see [[TextAnnotation2d.setAnnotation]] and [[TextAnnotation3d.setAnnotation]] to update the annotation, geometry, and placement of an annotation element.\r\n * @beta\r\n */\r\nexport function produceTextAnnotationGeometry(args: ProduceTextAnnotationGeometryArgs): TextBlockGeometryProps {\r\n const layout = layoutTextBlock({\r\n ...args,\r\n textBlock: args.annotation.textBlock,\r\n });\r\n\r\n const dimensions = layout.range;\r\n const transform = args.annotation.computeTransform(dimensions);\r\n\r\n const anchorPoint = args.debugAnchorPointAndRange ? args.annotation.computeAnchorPoint(dimensions) : undefined;\r\n return produceTextBlockGeometry(layout, transform, anchorPoint);\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"TextAnnotationGeometry.js","sourceRoot":"","sources":["../../src/TextAnnotationGeometry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAA+I;AAC/I,iEAA4I;AAC5I,wDAA4F;AAC5F,sDAA6C;AAQ7C,SAAS,QAAQ,CAAC,KAAqB,EAAE,OAAwB;IAC/D,IAAI,KAAK,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC/B,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC;QACzB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAClC,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY,EAAE,GAAc,EAAE,MAAgB;IACtE,IAAA,qBAAM,EAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAExB,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC;IAE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CAAC,CAAC;QAEjD,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;YACnB,SAAS,EAAE;gBACT,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;gBACtB,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;aACrB;SACF,CAAC,CAAC;QACH,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;YACnB,SAAS,EAAE;gBACT,UAAU,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;gBACtB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;aACrB;SACF,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;AACtC,CAAC;AAsBD;;;;GAIG;AACH,SAAgB,6BAA6B,CAAC,IAAuC;IACnF,MAAM,MAAM,GAAG,IAAA,sCAAe,EAAC;QAC7B,GAAG,IAAI;QACP,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,SAAS;KACrC,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC;IAChC,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAE/D,MAAM,WAAW,GAAG,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/G,OAAO,wBAAwB,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;AAClE,CAAC;AAXD,sEAWC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ElementGeometry\r\n */\r\n\r\nimport { ColorDef, TextAnnotation, TextBlockGeometryProps, TextBlockGeometryPropsEntry, TextString, TextStyleColor } from \"@itwin/core-common\";\r\nimport { ComputeRangesForTextLayout, FindFontId, FindTextStyle, layoutTextBlock, RunLayout, TextBlockLayout } from \"./TextAnnotationLayout\";\r\nimport { LineSegment3d, Point3d, Range2d, Transform, Vector2d } from \"@itwin/core-geometry\";\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { IModelDb } from \"./IModelDb\";\r\n\r\ninterface GeometryContext {\r\n curColor?: TextStyleColor;\r\n entries: TextBlockGeometryPropsEntry[];\r\n}\r\n\r\nfunction setColor(color: TextStyleColor, context: GeometryContext): void {\r\n if (color !== context.curColor) {\r\n context.curColor = color;\r\n context.entries.push({ color });\r\n }\r\n}\r\n\r\nfunction createTextString(text: string, run: RunLayout, origin?: Point3d): TextString {\r\n assert(text.length > 0);\r\n\r\n const { lineHeight, widthFactor, isBold, isItalic, isUnderlined } = run.style;\r\n\r\n return new TextString({\r\n text,\r\n font: run.fontId,\r\n height: lineHeight,\r\n widthFactor,\r\n bold: isBold,\r\n italic: isItalic,\r\n underline: isUnderlined,\r\n origin,\r\n });\r\n}\r\n\r\nfunction processTextRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\r\n assert(run.source.type === \"text\");\r\n const text = run.source.content.substring(run.charOffset, run.charOffset + run.numChars);\r\n if (text.length === 0) {\r\n return;\r\n }\r\n\r\n const ts = createTextString(text, run);\r\n if (\"none\" !== run.source.baselineShift) {\r\n const isSub = \"subscript\" === run.source.baselineShift;\r\n const offsetFactor = run.style[isSub ? \"subScriptOffsetFactor\" : \"superScriptOffsetFactor\"];\r\n const scale = run.style[isSub ? \"subScriptScale\" : \"superScriptScale\"];\r\n\r\n ts.origin.y += offsetFactor * ts.height;\r\n ts.height *= scale;\r\n }\r\n\r\n ts.transformInPlace(transform);\r\n\r\n setColor(run.style.color, context);\r\n context.entries.push({ text: ts});\r\n}\r\n\r\nfunction createFractionTextString(text: string, run: RunLayout, origin: Point3d, transform: Transform): TextString {\r\n const ts = createTextString(text, run, origin);\r\n assert(undefined !== ts.widthFactor);\r\n\r\n ts.height *= run.style.stackedFractionScale;\r\n\r\n ts.transformInPlace(transform);\r\n\r\n return ts;\r\n}\r\n\r\nfunction processFractionRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\r\n const source = run.source;\r\n assert(source.type === \"fraction\");\r\n\r\n if (source.numerator.length === 0 && source.denominator.length === 0) {\r\n return;\r\n }\r\n\r\n assert(undefined !== run.numeratorRange && undefined !== run.denominatorRange);\r\n\r\n const fontSize = new Vector2d(run.style.lineHeight * run.style.widthFactor, run.style.lineHeight);\r\n fontSize.scale(run.style.stackedFractionScale, fontSize);\r\n\r\n const numeratorOffset = new Point3d(run.numeratorRange.low.x, run.numeratorRange.low.y, 0);\r\n const denominatorOffset = new Point3d(run.denominatorRange.low.x, run.denominatorRange.low.y, 0);\r\n\r\n setColor(run.style.color, context);\r\n\r\n if (source.numerator.length > 0) {\r\n context.entries.push({ text: createFractionTextString(source.numerator, run, numeratorOffset, transform) });\r\n }\r\n\r\n const numeratorRange = Range2d.fromJSON(run.numeratorRange);\r\n const denominatorRange = Range2d.fromJSON(run.denominatorRange);\r\n\r\n let separator: LineSegment3d;\r\n if (run.style.stackedFractionType === \"horizontal\") {\r\n const fractionWidth = Math.max(numeratorRange.xLength(), denominatorRange.xLength());\r\n const y = 1.25 * denominatorRange.yLength();\r\n separator = LineSegment3d.createXYXY(0, y, fractionWidth, y);\r\n } else {\r\n const p0 = new Point3d(denominatorRange.low.x - fontSize.x / 2, denominatorRange.low.y + fontSize.y * (1 / 3), 0);\r\n const p1 = new Point3d(p0.x + fontSize.x, p0.y + fontSize.y * 1.5, 0);\r\n separator = LineSegment3d.createCapture(p0, p1);\r\n }\r\n\r\n separator.tryTransformInPlace(transform);\r\n\r\n context.entries.push({\r\n separator: {\r\n startPoint: separator.point0Ref.toJSON(),\r\n endPoint: separator.point1Ref.toJSON(),\r\n },\r\n });\r\n\r\n if (source.denominator.length > 0) {\r\n context.entries.push({ text: createFractionTextString(source.denominator, run,denominatorOffset, transform) });\r\n }\r\n}\r\n\r\nfunction produceTextBlockGeometry(layout: TextBlockLayout, documentTransform: Transform, debugAnchorPt?: Point3d): TextBlockGeometryProps {\r\n const context: GeometryContext = { entries: [] };\r\n for (const line of layout.lines) {\r\n const lineTrans = Transform.createTranslationXYZ(line.offsetFromDocument.x, line.offsetFromDocument.y, 0);\r\n for (const run of line.runs) {\r\n if (\"linebreak\" === run.source.type) {\r\n continue;\r\n }\r\n\r\n const runTrans = Transform.createTranslationXYZ(run.offsetFromLine.x, run.offsetFromLine.y, 0);\r\n lineTrans.multiplyTransformTransform(runTrans, runTrans);\r\n documentTransform.multiplyTransformTransform(runTrans, runTrans);\r\n if (\"text\" === run.source.type) {\r\n processTextRun(run, runTrans, context);\r\n } else {\r\n processFractionRun(run, runTrans, context);\r\n }\r\n }\r\n }\r\n\r\n if (debugAnchorPt) {\r\n // Draw lines representing the horizontal and vertical ranges, intersecting at the anchor point.\r\n context.entries.push({\r\n color: ColorDef.red.toJSON(),\r\n });\r\n\r\n const lx = layout.range.low.x - debugAnchorPt.x;\r\n const ly = layout.range.low.y - debugAnchorPt.y;\r\n const hx = layout.range.high.x - debugAnchorPt.x;\r\n const hy = layout.range.high.y - debugAnchorPt.y;\r\n\r\n context.entries.push({\r\n separator: {\r\n startPoint: [lx, 0, 0],\r\n endPoint: [hx, 0, 0],\r\n },\r\n });\r\n context.entries.push({\r\n separator: {\r\n startPoint: [0, ly, 0],\r\n endPoint: [0, hy, 0],\r\n },\r\n });\r\n }\r\n\r\n return { entries: context.entries };\r\n}\r\n\r\n/** Arguments supplied to [[produceTextAnnotationGeometry]].\r\n * @beta\r\n */\r\nexport interface ProduceTextAnnotationGeometryArgs {\r\n /** The annotation from which to produce the geometry. */\r\n annotation: TextAnnotation;\r\n /** The iModel from which to obtain fonts and text styles. */\r\n iModel: IModelDb;\r\n /** For debugging purposes only, whether to include geometry representing the bounding box and anchor point of the annotation.\r\n * If true, two red lines indicating the horizontal and vertical extents of the bounding box will be included, intersecting at the anchor point.\r\n */\r\n debugAnchorPointAndRange?: boolean;\r\n /** @internal chiefly for tests */\r\n computeTextRange?: ComputeRangesForTextLayout;\r\n /** @internal chiefly for tests */\r\n findTextStyle?: FindTextStyle;\r\n /** @internal chiefly for tests */\r\n findFontId?: FindFontId;\r\n}\r\n\r\n/** Produce a geometric representation of a text annotation, with the annotation's anchor point at the origin.\r\n * The result can be supplied to [GeometryStreamBuilder.appendTextBlock]($common).\r\n * @see [[TextAnnotation2d.setAnnotation]] and [[TextAnnotation3d.setAnnotation]] to update the annotation, geometry, and placement of an annotation element.\r\n * @beta\r\n */\r\nexport function produceTextAnnotationGeometry(args: ProduceTextAnnotationGeometryArgs): TextBlockGeometryProps {\r\n const layout = layoutTextBlock({\r\n ...args,\r\n textBlock: args.annotation.textBlock,\r\n });\r\n\r\n const dimensions = layout.range;\r\n const transform = args.annotation.computeTransform(dimensions);\r\n\r\n const anchorPoint = args.debugAnchorPointAndRange ? args.annotation.computeAnchorPoint(dimensions) : undefined;\r\n return produceTextBlockGeometry(layout, transform, anchorPoint);\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-backend",
|
|
3
|
-
"version": "4.8.0-dev.
|
|
3
|
+
"version": "4.8.0-dev.5",
|
|
4
4
|
"description": "iTwin.js backend components",
|
|
5
5
|
"main": "lib/cjs/core-backend.js",
|
|
6
6
|
"typings": "lib/cjs/core-backend",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"url": "http://www.bentley.com"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@itwin/core-bentley": "^4.8.0-dev.
|
|
29
|
-
"@itwin/core-common": "^4.8.0-dev.
|
|
30
|
-
"@itwin/core-geometry": "^4.8.0-dev.
|
|
28
|
+
"@itwin/core-bentley": "^4.8.0-dev.5",
|
|
29
|
+
"@itwin/core-common": "^4.8.0-dev.5",
|
|
30
|
+
"@itwin/core-geometry": "^4.8.0-dev.5",
|
|
31
31
|
"@opentelemetry/api": "^1.0.4"
|
|
32
32
|
},
|
|
33
33
|
"peerDependenciesMeta": {
|
|
@@ -69,16 +69,16 @@
|
|
|
69
69
|
"ts-node": "^10.8.2",
|
|
70
70
|
"typescript": "~5.3.3",
|
|
71
71
|
"webpack": "^5.76.0",
|
|
72
|
-
"@itwin/build-tools": "4.8.0-dev.
|
|
73
|
-
"@itwin/core-
|
|
74
|
-
"@itwin/core-
|
|
75
|
-
"@itwin/core-geometry": "4.8.0-dev.
|
|
76
|
-
"@itwin/
|
|
77
|
-
"@itwin/
|
|
72
|
+
"@itwin/build-tools": "4.8.0-dev.5",
|
|
73
|
+
"@itwin/core-common": "4.8.0-dev.5",
|
|
74
|
+
"@itwin/core-bentley": "4.8.0-dev.5",
|
|
75
|
+
"@itwin/core-geometry": "4.8.0-dev.5",
|
|
76
|
+
"@itwin/ecsql-common": "4.8.0-dev.5",
|
|
77
|
+
"@itwin/core-webpack-tools": "4.8.0-dev.5",
|
|
78
78
|
"internal-tools": "3.0.0-dev.69"
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@bentley/imodeljs-native": "4.8.
|
|
81
|
+
"@bentley/imodeljs-native": "4.8.1",
|
|
82
82
|
"@itwin/cloud-agnostic-core": "^2.1.0",
|
|
83
83
|
"@itwin/object-storage-azure": "^2.2.2",
|
|
84
84
|
"@itwin/object-storage-core": "^2.2.2",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"semver": "^7.3.5",
|
|
92
92
|
"touch": "^3.1.0",
|
|
93
93
|
"ws": "^7.5.3",
|
|
94
|
-
"@itwin/core-telemetry": "4.8.0-dev.
|
|
94
|
+
"@itwin/core-telemetry": "4.8.0-dev.5"
|
|
95
95
|
},
|
|
96
96
|
"nyc": {
|
|
97
97
|
"extends": "./node_modules/@itwin/build-tools/.nycrc"
|