@itwin/core-backend 4.6.0-dev.9 → 4.6.0
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 +31 -1
- package/lib/cjs/BackendHubAccess.js +1 -1
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/BackendLoggerCategory.d.ts +0 -5
- package/lib/cjs/BackendLoggerCategory.d.ts.map +1 -1
- package/lib/cjs/BackendLoggerCategory.js +1 -6
- package/lib/cjs/BackendLoggerCategory.js.map +1 -1
- package/lib/cjs/BisCoreSchema.d.ts.map +1 -1
- package/lib/cjs/BisCoreSchema.js +2 -0
- package/lib/cjs/BisCoreSchema.js.map +1 -1
- package/lib/cjs/BlobContainerService.js +1 -1
- package/lib/cjs/BlobContainerService.js.map +1 -1
- package/lib/cjs/BriefcaseManager.js +2 -2
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/Category.d.ts +1 -1
- package/lib/cjs/Category.js +1 -1
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.js +3 -3
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ChangedElementsDb.js.map +1 -1
- package/lib/cjs/ChangedElementsManager.js.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +239 -239
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/ChannelControl.js +2 -2
- package/lib/cjs/ChannelControl.js.map +1 -1
- package/lib/cjs/CheckpointManager.js +4 -4
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ClassRegistry.d.ts +3 -0
- package/lib/cjs/ClassRegistry.d.ts.map +1 -1
- package/lib/cjs/ClassRegistry.js +24 -13
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudSqlite.js +1 -1
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/CodeService.js +1 -1
- package/lib/cjs/CodeService.js.map +1 -1
- package/lib/cjs/CodeSpecs.js +1 -1
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
- package/lib/cjs/DevTools.js +2 -2
- package/lib/cjs/DevTools.js.map +1 -1
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECDb.js +1 -1
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/Element.d.ts +0 -16
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +7 -23
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.js +1 -1
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementGraphics.d.ts +0 -3
- package/lib/cjs/ElementGraphics.d.ts.map +1 -1
- package/lib/cjs/ElementGraphics.js +2 -5
- package/lib/cjs/ElementGraphics.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.d.ts.map +1 -1
- package/lib/cjs/ElementTreeWalker.js +5 -0
- package/lib/cjs/ElementTreeWalker.js.map +1 -1
- package/lib/cjs/Entity.js.map +1 -1
- package/lib/cjs/EntityReferences.js +1 -1
- package/lib/cjs/EntityReferences.js.map +1 -1
- package/lib/cjs/ExportGraphics.d.ts +1 -1
- package/lib/cjs/ExportGraphics.js +2 -2
- package/lib/cjs/ExportGraphics.js.map +1 -1
- package/lib/cjs/ExternalSource.js.map +1 -1
- package/lib/cjs/GeoCoordConfig.js +1 -1
- package/lib/cjs/GeoCoordConfig.js.map +1 -1
- package/lib/cjs/GeometrySummary.js +47 -47
- package/lib/cjs/GeometrySummary.js.map +1 -1
- package/lib/cjs/HubMock.js +1 -1
- package/lib/cjs/HubMock.js.map +1 -1
- package/lib/cjs/IModelCloneContext.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +8 -2
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +70 -29
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelElementCloneContext.js.map +1 -1
- package/lib/cjs/IModelHost.js +2 -2
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/IpcHost.js +1 -1
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LineStyle.d.ts +1 -1
- package/lib/cjs/LineStyle.js +2 -2
- package/lib/cjs/LineStyle.js.map +1 -1
- package/lib/cjs/LocalHub.js +1 -1
- package/lib/cjs/LocalHub.js.map +1 -1
- package/lib/cjs/LocalhostIpcHost.js +1 -1
- package/lib/cjs/LocalhostIpcHost.js.map +1 -1
- package/lib/cjs/Material.js +1 -1
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/NativeAppStorage.js +1 -1
- package/lib/cjs/NativeAppStorage.js.map +1 -1
- package/lib/cjs/NativeHost.js +1 -1
- package/lib/cjs/NativeHost.js.map +1 -1
- package/lib/cjs/NavigationRelationship.js +21 -21
- package/lib/cjs/NavigationRelationship.js.map +1 -1
- package/lib/cjs/PromiseMemoizer.d.ts +0 -3
- package/lib/cjs/PromiseMemoizer.d.ts.map +1 -1
- package/lib/cjs/PromiseMemoizer.js +2 -5
- package/lib/cjs/PromiseMemoizer.js.map +1 -1
- package/lib/cjs/PropertyStore.js +1 -1
- package/lib/cjs/PropertyStore.js.map +1 -1
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/SQLiteDb.js +2 -2
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/Schema.js +1 -1
- package/lib/cjs/Schema.js.map +1 -1
- package/lib/cjs/SchemaSync.js +1 -1
- package/lib/cjs/SchemaSync.js.map +1 -1
- package/lib/cjs/SchemaUtils.js.map +1 -1
- package/lib/cjs/ServerBasedLocks.js.map +1 -1
- package/lib/cjs/SqliteChangesetReader.js.map +1 -1
- package/lib/cjs/SqliteStatement.js +2 -2
- package/lib/cjs/SqliteStatement.js.map +1 -1
- package/lib/cjs/TextAnnotationElement.d.ts +54 -0
- package/lib/cjs/TextAnnotationElement.d.ts.map +1 -0
- package/lib/cjs/TextAnnotationElement.js +94 -0
- package/lib/cjs/TextAnnotationElement.js.map +1 -0
- package/lib/cjs/TextAnnotationGeometry.d.ts +28 -0
- package/lib/cjs/TextAnnotationGeometry.d.ts.map +1 -0
- package/lib/cjs/TextAnnotationGeometry.js +154 -0
- package/lib/cjs/TextAnnotationGeometry.js.map +1 -0
- package/lib/cjs/TextAnnotationLayout.d.ts +124 -0
- package/lib/cjs/TextAnnotationLayout.d.ts.map +1 -0
- package/lib/cjs/TextAnnotationLayout.js +399 -0
- package/lib/cjs/TextAnnotationLayout.js.map +1 -0
- package/lib/cjs/Texture.js.map +1 -1
- package/lib/cjs/TileStorage.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +53 -1
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.js +4 -4
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/ViewStateHydrator.d.ts +1 -0
- package/lib/cjs/ViewStateHydrator.d.ts.map +1 -1
- package/lib/cjs/ViewStateHydrator.js +1 -0
- package/lib/cjs/ViewStateHydrator.js.map +1 -1
- package/lib/cjs/ViewStore.js +1 -1
- package/lib/cjs/ViewStore.js.map +1 -1
- package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
- package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +44 -44
- package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +31 -31
- package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +52 -52
- package/lib/cjs/assets/Settings/backend.setting.json5 +132 -132
- package/lib/cjs/core-backend.d.ts +46 -61
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +46 -61
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/domains/FunctionalElements.js +1 -1
- package/lib/cjs/domains/FunctionalElements.js.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
- package/lib/cjs/domains/GenericElements.js.map +1 -1
- package/lib/cjs/domains/GenericSchema.js.map +1 -1
- package/lib/cjs/rpc/multipart.js.map +1 -1
- package/lib/cjs/rpc/tracing.js +2 -2
- package/lib/cjs/rpc/tracing.js.map +1 -1
- package/lib/cjs/rpc/web/logging.js +2 -2
- package/lib/cjs/rpc/web/logging.js.map +1 -1
- package/lib/cjs/rpc/web/request.js.map +1 -1
- package/lib/cjs/rpc/web/response.js +1 -1
- package/lib/cjs/rpc/web/response.js.map +1 -1
- package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/Settings.js +1 -1
- package/lib/cjs/workspace/Settings.js.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.d.ts +0 -5
- package/lib/cjs/workspace/SettingsSchemas.d.ts.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.js +1 -10
- package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
- package/lib/cjs/workspace/Workspace.js +4 -4
- package/lib/cjs/workspace/Workspace.js.map +1 -1
- package/package.json +14 -14
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module ElementGeometry
|
|
3
|
+
*/
|
|
4
|
+
import { TextAnnotation, TextBlockGeometryProps } from "@itwin/core-common";
|
|
5
|
+
import { ComputeRangesForTextLayout, FindFontId, FindTextStyle } from "./TextAnnotationLayout";
|
|
6
|
+
import { IModelDb } from "./IModelDb";
|
|
7
|
+
/** Arguments supplied to [[produceTextAnnotationGeometry]].
|
|
8
|
+
* @beta
|
|
9
|
+
*/
|
|
10
|
+
export interface ProduceTextAnnotationGeometryArgs {
|
|
11
|
+
/** The annotation from which to produce the geometry. */
|
|
12
|
+
annotation: TextAnnotation;
|
|
13
|
+
/** The iModel from which to obtain fonts and text styles. */
|
|
14
|
+
iModel: IModelDb;
|
|
15
|
+
/** @internal chiefly for tests */
|
|
16
|
+
computeTextRange?: ComputeRangesForTextLayout;
|
|
17
|
+
/** @internal chiefly for tests */
|
|
18
|
+
findTextStyle?: FindTextStyle;
|
|
19
|
+
/** @internal chiefly for tests */
|
|
20
|
+
findFontId?: FindFontId;
|
|
21
|
+
}
|
|
22
|
+
/** Produce a geometric representation of a text annotation.
|
|
23
|
+
* The result can be supplied to [GeometryStreamBuilder.appendTextBlock]($common).
|
|
24
|
+
* @see [[TextAnnotation2d.setAnnotation]] and [[TextAnnotation3d.setAnnotation]] to update the annotation, geometry, and placement of an annotation element.
|
|
25
|
+
* @beta
|
|
26
|
+
*/
|
|
27
|
+
export declare function produceTextAnnotationGeometry(args: ProduceTextAnnotationGeometryArgs): TextBlockGeometryProps;
|
|
28
|
+
//# sourceMappingURL=TextAnnotationGeometry.d.ts.map
|
|
@@ -0,0 +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;AA8JtC;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD,yDAAyD;IACzD,UAAU,EAAE,cAAc,CAAC;IAC3B,6DAA6D;IAC7D,MAAM,EAAE,QAAQ,CAAC;IACjB,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"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module ElementGeometry
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.produceTextAnnotationGeometry = void 0;
|
|
11
|
+
const core_common_1 = require("@itwin/core-common");
|
|
12
|
+
const TextAnnotationLayout_1 = require("./TextAnnotationLayout");
|
|
13
|
+
const core_geometry_1 = require("@itwin/core-geometry");
|
|
14
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
15
|
+
function setColor(color, context) {
|
|
16
|
+
if (color !== context.curColor) {
|
|
17
|
+
context.curColor = color;
|
|
18
|
+
context.entries.push({ color });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function createTextString(text, run, origin) {
|
|
22
|
+
(0, core_bentley_1.assert)(text.length > 0);
|
|
23
|
+
const { lineHeight, widthFactor, isBold, isItalic, isUnderlined } = run.style;
|
|
24
|
+
return new core_common_1.TextString({
|
|
25
|
+
text,
|
|
26
|
+
font: run.fontId,
|
|
27
|
+
height: lineHeight,
|
|
28
|
+
widthFactor,
|
|
29
|
+
bold: isBold,
|
|
30
|
+
italic: isItalic,
|
|
31
|
+
underline: isUnderlined,
|
|
32
|
+
origin,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function processTextRun(run, transform, context) {
|
|
36
|
+
(0, core_bentley_1.assert)(run.source.type === "text");
|
|
37
|
+
const text = run.source.content.substring(run.charOffset, run.charOffset + run.numChars);
|
|
38
|
+
if (text.length === 0) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const ts = createTextString(text, run);
|
|
42
|
+
if ("none" !== run.source.baselineShift) {
|
|
43
|
+
const isSub = "subscript" === run.source.baselineShift;
|
|
44
|
+
const offsetFactor = run.style[isSub ? "subScriptOffsetFactor" : "superScriptOffsetFactor"];
|
|
45
|
+
const scale = run.style[isSub ? "subScriptScale" : "superScriptScale"];
|
|
46
|
+
ts.origin.y += offsetFactor * ts.height;
|
|
47
|
+
ts.height *= scale;
|
|
48
|
+
}
|
|
49
|
+
ts.transformInPlace(transform);
|
|
50
|
+
setColor(run.style.color, context);
|
|
51
|
+
context.entries.push({ text: ts });
|
|
52
|
+
}
|
|
53
|
+
function createFractionTextString(text, run, origin, transform) {
|
|
54
|
+
const ts = createTextString(text, run, origin);
|
|
55
|
+
(0, core_bentley_1.assert)(undefined !== ts.widthFactor);
|
|
56
|
+
ts.height *= run.style.stackedFractionScale;
|
|
57
|
+
ts.transformInPlace(transform);
|
|
58
|
+
return ts;
|
|
59
|
+
}
|
|
60
|
+
function processFractionRun(run, transform, context) {
|
|
61
|
+
const source = run.source;
|
|
62
|
+
(0, core_bentley_1.assert)(source.type === "fraction");
|
|
63
|
+
if (source.numerator.length === 0 && source.denominator.length === 0) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
(0, core_bentley_1.assert)(undefined !== run.numeratorRange && undefined !== run.denominatorRange);
|
|
67
|
+
const fontSize = new core_geometry_1.Vector2d(run.style.lineHeight * run.style.widthFactor, run.style.lineHeight);
|
|
68
|
+
fontSize.scale(run.style.stackedFractionScale, fontSize);
|
|
69
|
+
const numeratorOffset = new core_geometry_1.Point3d(run.numeratorRange.low.x, run.numeratorRange.low.y, 0);
|
|
70
|
+
const denominatorOffset = new core_geometry_1.Point3d(run.denominatorRange.low.x, run.denominatorRange.low.y, 0);
|
|
71
|
+
setColor(run.style.color, context);
|
|
72
|
+
if (source.numerator.length > 0) {
|
|
73
|
+
context.entries.push({ text: createFractionTextString(source.numerator, run, numeratorOffset, transform) });
|
|
74
|
+
}
|
|
75
|
+
const numeratorRange = core_geometry_1.Range2d.fromJSON(run.numeratorRange);
|
|
76
|
+
const denominatorRange = core_geometry_1.Range2d.fromJSON(run.denominatorRange);
|
|
77
|
+
let separator;
|
|
78
|
+
if (run.style.stackedFractionType === "horizontal") {
|
|
79
|
+
const fractionWidth = Math.max(numeratorRange.xLength(), denominatorRange.xLength());
|
|
80
|
+
const y = 1.25 * denominatorRange.yLength();
|
|
81
|
+
separator = core_geometry_1.LineSegment3d.createXYXY(0, y, fractionWidth, y);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const p0 = new core_geometry_1.Point3d(denominatorRange.low.x - fontSize.x / 2, denominatorRange.low.y + fontSize.y * (1 / 3), 0);
|
|
85
|
+
const p1 = new core_geometry_1.Point3d(p0.x + fontSize.x, p0.y + fontSize.y * 1.5, 0);
|
|
86
|
+
separator = core_geometry_1.LineSegment3d.createCapture(p0, p1);
|
|
87
|
+
}
|
|
88
|
+
separator.tryTransformInPlace(transform);
|
|
89
|
+
context.entries.push({
|
|
90
|
+
separator: {
|
|
91
|
+
startPoint: separator.point0Ref.toJSON(),
|
|
92
|
+
endPoint: separator.point1Ref.toJSON(),
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
if (source.denominator.length > 0) {
|
|
96
|
+
context.entries.push({ text: createFractionTextString(source.denominator, run, denominatorOffset, transform) });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function produceTextBlockGeometry(layout, documentTransform, debugAnchorPt) {
|
|
100
|
+
const context = { entries: [] };
|
|
101
|
+
for (const line of layout.lines) {
|
|
102
|
+
const lineTrans = core_geometry_1.Transform.createTranslationXYZ(line.offsetFromDocument.x, line.offsetFromDocument.y, 0);
|
|
103
|
+
for (const run of line.runs) {
|
|
104
|
+
if ("linebreak" === run.source.type) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const runTrans = core_geometry_1.Transform.createTranslationXYZ(run.offsetFromLine.x, run.offsetFromLine.y, 0);
|
|
108
|
+
lineTrans.multiplyTransformTransform(runTrans, runTrans);
|
|
109
|
+
documentTransform.multiplyTransformTransform(runTrans, runTrans);
|
|
110
|
+
if ("text" === run.source.type) {
|
|
111
|
+
processTextRun(run, runTrans, context);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
processFractionRun(run, runTrans, context);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (debugAnchorPt) {
|
|
119
|
+
// Draw lines representing the horizontal and vertical ranges, intersecting at the anchor point.
|
|
120
|
+
context.entries.push({
|
|
121
|
+
color: core_common_1.ColorDef.red.toJSON(),
|
|
122
|
+
});
|
|
123
|
+
context.entries.push({
|
|
124
|
+
separator: {
|
|
125
|
+
startPoint: [layout.range.low.x, debugAnchorPt.y, 0],
|
|
126
|
+
endPoint: [layout.range.high.x, debugAnchorPt.y, 0],
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
context.entries.push({
|
|
130
|
+
separator: {
|
|
131
|
+
startPoint: [debugAnchorPt.x, layout.range.low.y, 0],
|
|
132
|
+
endPoint: [debugAnchorPt.x, layout.range.high.y, 0],
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return { entries: context.entries };
|
|
137
|
+
}
|
|
138
|
+
/** Produce a geometric representation of a text annotation.
|
|
139
|
+
* The result can be supplied to [GeometryStreamBuilder.appendTextBlock]($common).
|
|
140
|
+
* @see [[TextAnnotation2d.setAnnotation]] and [[TextAnnotation3d.setAnnotation]] to update the annotation, geometry, and placement of an annotation element.
|
|
141
|
+
* @beta
|
|
142
|
+
*/
|
|
143
|
+
function produceTextAnnotationGeometry(args) {
|
|
144
|
+
const layout = (0, TextAnnotationLayout_1.layoutTextBlock)({
|
|
145
|
+
...args,
|
|
146
|
+
textBlock: args.annotation.textBlock,
|
|
147
|
+
});
|
|
148
|
+
const transform = args.annotation.computeDocumentTransform(layout.range);
|
|
149
|
+
const debugAnchorPointAndRange = false;
|
|
150
|
+
const anchorPoint = debugAnchorPointAndRange ? args.annotation.computeAnchorPoint(layout.range) : undefined;
|
|
151
|
+
return produceTextBlockGeometry(layout, transform, anchorPoint);
|
|
152
|
+
}
|
|
153
|
+
exports.produceTextAnnotationGeometry = produceTextAnnotationGeometry;
|
|
154
|
+
//# sourceMappingURL=TextAnnotationGeometry.js.map
|
|
@@ -0,0 +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,UAAU,EAAE,WAAW,EAAE,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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;AAkBD;;;;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,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,wBAAwB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEzE,MAAM,wBAAwB,GAAG,KAAK,CAAC;IACvC,MAAM,WAAW,GAAG,wBAAwB,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5G,OAAO,wBAAwB,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;AAClE,CAAC;AAXD,sEAWC","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, TextAnnotation, TextBlockGeometryProps, TextBlockGeometryPropsEntry, TextString, TextStyleColor } from \"@itwin/core-common\";\nimport { ComputeRangesForTextLayout, FindFontId, FindTextStyle, layoutTextBlock, RunLayout, TextBlockLayout } from \"./TextAnnotationLayout\";\nimport { LineSegment3d, Point3d, Range2d, Transform, Vector2d } from \"@itwin/core-geometry\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { IModelDb } from \"./IModelDb\";\n\ninterface GeometryContext {\n curColor?: TextStyleColor;\n entries: TextBlockGeometryPropsEntry[];\n}\n\nfunction setColor(color: TextStyleColor, context: GeometryContext): void {\n if (color !== context.curColor) {\n context.curColor = color;\n context.entries.push({ color });\n }\n}\n\nfunction createTextString(text: string, run: RunLayout, origin?: Point3d): TextString {\n assert(text.length > 0);\n\n const { lineHeight, widthFactor, isBold, isItalic, isUnderlined } = run.style;\n\n return new TextString({\n text,\n font: run.fontId,\n height: lineHeight,\n widthFactor,\n bold: isBold,\n italic: isItalic,\n underline: isUnderlined,\n origin,\n });\n}\n\nfunction processTextRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\n assert(run.source.type === \"text\");\n const text = run.source.content.substring(run.charOffset, run.charOffset + run.numChars);\n if (text.length === 0) {\n return;\n }\n\n const ts = createTextString(text, run);\n if (\"none\" !== run.source.baselineShift) {\n const isSub = \"subscript\" === run.source.baselineShift;\n const offsetFactor = run.style[isSub ? \"subScriptOffsetFactor\" : \"superScriptOffsetFactor\"];\n const scale = run.style[isSub ? \"subScriptScale\" : \"superScriptScale\"];\n\n ts.origin.y += offsetFactor * ts.height;\n ts.height *= scale;\n }\n\n ts.transformInPlace(transform);\n\n setColor(run.style.color, context);\n context.entries.push({ text: ts});\n}\n\nfunction createFractionTextString(text: string, run: RunLayout, origin: Point3d, transform: Transform): TextString {\n const ts = createTextString(text, run, origin);\n assert(undefined !== ts.widthFactor);\n\n ts.height *= run.style.stackedFractionScale;\n\n ts.transformInPlace(transform);\n\n return ts;\n}\n\nfunction processFractionRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\n const source = run.source;\n assert(source.type === \"fraction\");\n\n if (source.numerator.length === 0 && source.denominator.length === 0) {\n return;\n }\n\n assert(undefined !== run.numeratorRange && undefined !== run.denominatorRange);\n\n const fontSize = new Vector2d(run.style.lineHeight * run.style.widthFactor, run.style.lineHeight);\n fontSize.scale(run.style.stackedFractionScale, fontSize);\n\n const numeratorOffset = new Point3d(run.numeratorRange.low.x, run.numeratorRange.low.y, 0);\n const denominatorOffset = new Point3d(run.denominatorRange.low.x, run.denominatorRange.low.y, 0);\n\n setColor(run.style.color, context);\n\n if (source.numerator.length > 0) {\n context.entries.push({ text: createFractionTextString(source.numerator, run, numeratorOffset, transform) });\n }\n\n const numeratorRange = Range2d.fromJSON(run.numeratorRange);\n const denominatorRange = Range2d.fromJSON(run.denominatorRange);\n\n let separator: LineSegment3d;\n if (run.style.stackedFractionType === \"horizontal\") {\n const fractionWidth = Math.max(numeratorRange.xLength(), denominatorRange.xLength());\n const y = 1.25 * denominatorRange.yLength();\n separator = LineSegment3d.createXYXY(0, y, fractionWidth, y);\n } else {\n const p0 = new Point3d(denominatorRange.low.x - fontSize.x / 2, denominatorRange.low.y + fontSize.y * (1 / 3), 0);\n const p1 = new Point3d(p0.x + fontSize.x, p0.y + fontSize.y * 1.5, 0);\n separator = LineSegment3d.createCapture(p0, p1);\n }\n\n separator.tryTransformInPlace(transform);\n\n context.entries.push({\n separator: {\n startPoint: separator.point0Ref.toJSON(),\n endPoint: separator.point1Ref.toJSON(),\n },\n });\n\n if (source.denominator.length > 0) {\n context.entries.push({ text: createFractionTextString(source.denominator, run,denominatorOffset, transform) });\n }\n}\n\nfunction produceTextBlockGeometry(layout: TextBlockLayout, documentTransform: Transform, debugAnchorPt?: Point3d): TextBlockGeometryProps {\n const context: GeometryContext = { entries: [] };\n for (const line of layout.lines) {\n const lineTrans = Transform.createTranslationXYZ(line.offsetFromDocument.x, line.offsetFromDocument.y, 0);\n for (const run of line.runs) {\n if (\"linebreak\" === run.source.type) {\n continue;\n }\n\n const runTrans = Transform.createTranslationXYZ(run.offsetFromLine.x, run.offsetFromLine.y, 0);\n lineTrans.multiplyTransformTransform(runTrans, runTrans);\n documentTransform.multiplyTransformTransform(runTrans, runTrans);\n if (\"text\" === run.source.type) {\n processTextRun(run, runTrans, context);\n } else {\n processFractionRun(run, runTrans, context);\n }\n }\n }\n\n if (debugAnchorPt) {\n // Draw lines representing the horizontal and vertical ranges, intersecting at the anchor point.\n context.entries.push({\n color: ColorDef.red.toJSON(),\n });\n\n context.entries.push({\n separator: {\n startPoint: [layout.range.low.x, debugAnchorPt.y, 0],\n endPoint: [layout.range.high.x, debugAnchorPt.y, 0],\n },\n });\n context.entries.push({\n separator: {\n startPoint: [debugAnchorPt.x, layout.range.low.y, 0],\n endPoint: [debugAnchorPt.x, layout.range.high.y, 0],\n },\n });\n }\n\n return { entries: context.entries };\n}\n\n/** Arguments supplied to [[produceTextAnnotationGeometry]].\n * @beta\n */\nexport interface ProduceTextAnnotationGeometryArgs {\n /** The annotation from which to produce the geometry. */\n annotation: TextAnnotation;\n /** The iModel from which to obtain fonts and text styles. */\n iModel: IModelDb;\n /** @internal chiefly for tests */\n computeTextRange?: ComputeRangesForTextLayout;\n /** @internal chiefly for tests */\n findTextStyle?: FindTextStyle;\n /** @internal chiefly for tests */\n findFontId?: FindFontId;\n}\n\n/** Produce a geometric representation of a text annotation.\n * The result can be supplied to [GeometryStreamBuilder.appendTextBlock]($common).\n * @see [[TextAnnotation2d.setAnnotation]] and [[TextAnnotation3d.setAnnotation]] to update the annotation, geometry, and placement of an annotation element.\n * @beta\n */\nexport function produceTextAnnotationGeometry(args: ProduceTextAnnotationGeometryArgs): TextBlockGeometryProps {\n const layout = layoutTextBlock({\n ...args,\n textBlock: args.annotation.textBlock,\n });\n\n const transform = args.annotation.computeDocumentTransform(layout.range);\n\n const debugAnchorPointAndRange = false;\n const anchorPoint = debugAnchorPointAndRange ? args.annotation.computeAnchorPoint(layout.range) : undefined;\n return produceTextBlockGeometry(layout, transform, anchorPoint);\n}\n"]}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { BaselineShift, FontId, FractionRun, Paragraph, Run, TextBlock, TextRun, TextStyleSettings } from "@itwin/core-common";
|
|
2
|
+
import { Range2d } from "@itwin/core-geometry";
|
|
3
|
+
import { IModelDb } from "./IModelDb";
|
|
4
|
+
/** @internal */
|
|
5
|
+
export interface TextLayoutRanges {
|
|
6
|
+
layout: Range2d;
|
|
7
|
+
justification: Range2d;
|
|
8
|
+
}
|
|
9
|
+
/** Arguments to [[ComputeRangesForTextLayout]].
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export interface ComputeRangesForTextLayoutArgs {
|
|
13
|
+
chars: string;
|
|
14
|
+
bold: boolean;
|
|
15
|
+
italic: boolean;
|
|
16
|
+
baselineShift: BaselineShift;
|
|
17
|
+
fontId: FontId;
|
|
18
|
+
widthFactor: number;
|
|
19
|
+
lineHeight: number;
|
|
20
|
+
}
|
|
21
|
+
/** A function that uses a font to compute the layout and justification ranges of a string of text.
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export type ComputeRangesForTextLayout = (args: ComputeRangesForTextLayoutArgs) => TextLayoutRanges;
|
|
25
|
+
/** @internal */
|
|
26
|
+
export type FindFontId = (name: string) => FontId;
|
|
27
|
+
/** @internal */
|
|
28
|
+
export type FindTextStyle = (name: string) => TextStyleSettings;
|
|
29
|
+
/** @internal */
|
|
30
|
+
export interface LayoutTextBlockArgs {
|
|
31
|
+
textBlock: TextBlock;
|
|
32
|
+
iModel: IModelDb;
|
|
33
|
+
/** @internal chiefly for tests, by default uses IModelJsNative.DgnDb.computeRangesForText. */
|
|
34
|
+
computeTextRange?: ComputeRangesForTextLayout;
|
|
35
|
+
/** @internal chiefly for tests, by default looks up styles from a workspace. */
|
|
36
|
+
findTextStyle?: FindTextStyle;
|
|
37
|
+
/** @internal chiefly for tests, by default uses IModelDb.fontMap. */
|
|
38
|
+
findFontId?: FindFontId;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Lays out the contents of a TextBlock into a series of lines containing runs.
|
|
42
|
+
* Each paragraph is decomposed into a series of lines.
|
|
43
|
+
* Each series of consecutive non-linebreak runs within a paragraph is concatenated into one line.
|
|
44
|
+
* If the document specifies a width > 0, individual lines are split to try to avoid exceeding that width.
|
|
45
|
+
* Individual TextRuns can be split onto multiple lines at word boundaries if necessary. Individual FractionRuns are never split.
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export declare function layoutTextBlock(args: LayoutTextBlockArgs): TextBlockLayout;
|
|
49
|
+
declare class LayoutContext {
|
|
50
|
+
private readonly _computeTextRange;
|
|
51
|
+
private readonly _findTextStyle;
|
|
52
|
+
private readonly _findFontId;
|
|
53
|
+
private readonly _textStyles;
|
|
54
|
+
private readonly _fontIds;
|
|
55
|
+
readonly blockSettings: TextStyleSettings;
|
|
56
|
+
constructor(block: TextBlock, _computeTextRange: ComputeRangesForTextLayout, _findTextStyle: FindTextStyle, _findFontId: FindFontId);
|
|
57
|
+
findFontId(name: string): FontId;
|
|
58
|
+
findTextStyle(name: string): TextStyleSettings;
|
|
59
|
+
createRunSettings(run: Run): TextStyleSettings;
|
|
60
|
+
computeRangeForText(chars: string, style: TextStyleSettings, baselineShift: BaselineShift): TextLayoutRanges;
|
|
61
|
+
computeRangeForTextRun(style: TextStyleSettings, run: TextRun, charOffset: number, numChars: number): TextLayoutRanges;
|
|
62
|
+
computeRangeForFractionRun(style: TextStyleSettings, source: FractionRun): {
|
|
63
|
+
layout: Range2d;
|
|
64
|
+
numerator: Range2d;
|
|
65
|
+
denominator: Range2d;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** @internal */
|
|
69
|
+
export declare class RunLayout {
|
|
70
|
+
source: Run;
|
|
71
|
+
charOffset: number;
|
|
72
|
+
numChars: number;
|
|
73
|
+
range: Range2d;
|
|
74
|
+
justificationRange?: Range2d;
|
|
75
|
+
denominatorRange?: Range2d;
|
|
76
|
+
numeratorRange?: Range2d;
|
|
77
|
+
offsetFromLine: {
|
|
78
|
+
x: number;
|
|
79
|
+
y: number;
|
|
80
|
+
};
|
|
81
|
+
style: TextStyleSettings;
|
|
82
|
+
fontId: FontId;
|
|
83
|
+
private constructor();
|
|
84
|
+
static create(source: Run, context: LayoutContext): RunLayout;
|
|
85
|
+
canWrap(): this is {
|
|
86
|
+
source: TextRun;
|
|
87
|
+
};
|
|
88
|
+
private cloneForWrap;
|
|
89
|
+
wrap(availableWidth: number, shouldForceLeadingUnit: boolean, context: LayoutContext): RunLayout | undefined;
|
|
90
|
+
}
|
|
91
|
+
/** @internal */
|
|
92
|
+
export declare class LineLayout {
|
|
93
|
+
source: Paragraph;
|
|
94
|
+
range: Range2d;
|
|
95
|
+
justificationRange: Range2d;
|
|
96
|
+
offsetFromDocument: {
|
|
97
|
+
x: number;
|
|
98
|
+
y: number;
|
|
99
|
+
};
|
|
100
|
+
private _runs;
|
|
101
|
+
constructor(source: Paragraph);
|
|
102
|
+
get runs(): ReadonlyArray<RunLayout>;
|
|
103
|
+
get isEmpty(): boolean;
|
|
104
|
+
get back(): RunLayout;
|
|
105
|
+
append(run: RunLayout): void;
|
|
106
|
+
/** Invoked every time a run is appended,. */
|
|
107
|
+
private computeRanges;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Describes the layout of a text block as a collection of lines containing runs.
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
113
|
+
export declare class TextBlockLayout {
|
|
114
|
+
source: TextBlock;
|
|
115
|
+
range: Range2d;
|
|
116
|
+
lines: LineLayout[];
|
|
117
|
+
constructor(source: TextBlock, context: LayoutContext);
|
|
118
|
+
private get _back();
|
|
119
|
+
private populateLines;
|
|
120
|
+
private justifyLines;
|
|
121
|
+
private flushLine;
|
|
122
|
+
}
|
|
123
|
+
export {};
|
|
124
|
+
//# sourceMappingURL=TextAnnotationLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextAnnotationLayout.d.ts","sourceRoot":"","sources":["../../src/TextAnnotationLayout.ts"],"names":[],"mappings":"AAKA,OA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