@edubeam/plot 0.1.0 → 0.3.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 +88 -0
- package/dist/components/StructurePlot.vue.d.ts +1 -2
- package/dist/components/texts.d.ts +24 -0
- package/dist/components/theme.d.ts +3 -3
- package/dist/components/types.d.ts +12 -2
- package/dist/core/layout.d.ts +23 -0
- package/dist/core/model.d.ts +4 -1
- package/dist/core/polynomial.d.ts +0 -1
- package/dist/core/readout.d.ts +59 -7
- package/dist/core/scene.d.ts +73 -6
- package/dist/core/structure.d.ts +151 -5
- package/dist/core/svg.d.ts +76 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.js +2282 -1231
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,94 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@edubeam/plot` are listed here. The project follows [Semantic Versioning](https://semver.org).
|
|
4
4
|
|
|
5
|
+
## 0.3.0 (2026-11-20)
|
|
6
|
+
|
|
7
|
+
- **Drawing for an editor**: the options the EduBeam app's new renderer draws with, all off by default.
|
|
8
|
+
`sizes` overrides the symbols' px sizes; `loadLabels: 'ends'` writes a distributed load at both ends as bare
|
|
9
|
+
numbers; `constantDiagrams: 'ends'` and `cornerValues: 'each'` annotate every segment and every member's end;
|
|
10
|
+
`splitLoads` draws a load's two components as the two loads they were entered as; `sideBySide` stands two
|
|
11
|
+
values written along one ordinate line side by side, each half a line aside, rather than one pushed out;
|
|
12
|
+
`freeNodes` draws nodes no member reaches yet; `labelsAvoidSupports`, `displacementText`, `diagramFill`
|
|
13
|
+
(`hatch`, `solid`, `none`), `showDegrees`, `normalOnDashedSide`, `shearOnDashedSide` and `supportScale` follow
|
|
14
|
+
the app's settings.
|
|
15
|
+
- **Member names**: a `memberLabels` layer writes each member's name once, along it and never upside down.
|
|
16
|
+
- **Loads that push the same way stack**, as a textbook draws them: a second band on top of the first, a point
|
|
17
|
+
load's arrow beyond the last one's value.
|
|
18
|
+
- **Reactions on their line of action**: every reaction force, the horizontal ones too, now points at its node.
|
|
19
|
+
- A diagram running straight on through a node writes the value it has on both sides once.
|
|
20
|
+
- **Pointing at things**: paths, circles and texts carry the `entity` they draw (`member:…`, `node:…`,
|
|
21
|
+
`elementLoad:…`, `nodalLoad:…`), loads carry their `source` from `modelFromSolver`, and each distributed
|
|
22
|
+
load has an undrawn `hitArea` path covering its band, so an app can highlight or hit-test what it shows.
|
|
23
|
+
- **Values at the pointer**: `placeReadoutTags` places a readout's tags beside their diagram points, outward
|
|
24
|
+
only and inside a viewport; `readMember` and `readoutAt` snap to a member's ends and, for the quantities read,
|
|
25
|
+
to their interior extremes (the largest moment, where the shear is zero, first); `formatReadout` takes a
|
|
26
|
+
writer for displacements.
|
|
27
|
+
- **Label priorities**: `resolveScene` takes `lateGroups` (placed after the given data), `yieldingGroups` (give
|
|
28
|
+
way to every other label) and `keptGroups` (never left out), and reports the painted `bounds`. A text placement
|
|
29
|
+
marked `acrossDiagrams` may cross another diagram's outline.
|
|
30
|
+
- A structure drawn at an extreme zoom (a fit's first probe) no longer runs out of memory: a member gets at most
|
|
31
|
+
500 load arrows or hatch lines, spaced wider when it is longer.
|
|
32
|
+
- **Faster**: labels are placed against a spatial grid (a 375-member frame placed in 0.3 s, down from 10 s),
|
|
33
|
+
`mergePaths` joins alike paths (a band of thirty arrows becomes two paths), and diagram maxima are cached.
|
|
34
|
+
- **`sceneSvg`** writes a scene laid out by an application as a standalone `.svg` file, and **`sceneMarkup`** as
|
|
35
|
+
markup for an SVG of its own, with the same Word- and Inkscape-safe output as `structureSvg`.
|
|
36
|
+
- `SymbolSizes` is exported.
|
|
37
|
+
|
|
38
|
+
## 0.2.0 (2026-11-19)
|
|
39
|
+
|
|
40
|
+
- **Translatable screen-reader texts**: `PLOT_TEXTS` (an injection key) lets an app give the figure's accessible
|
|
41
|
+
name and the movable load's slider texts in its own language, `app.provide(PLOT_TEXTS, { structure: (layers) => … })`,
|
|
42
|
+
or a ref of them to follow a language switch. English stays the default, and a `title` prop still wins.
|
|
43
|
+
`temperature` sets the temperature load's symbols on the figure (`temperatureSymbols` in `structureSvg`):
|
|
44
|
+
`ΔT` and `ΔTb − ΔTt` unless given, `ΔTs` and `ΔTd − ΔTh` in the Czech app.
|
|
45
|
+
- **Bottom fibres**: every member has the app's thin dashed line beside it, on its local +z side, so a drawing
|
|
46
|
+
shows which face a positive bending moment stretches. It belongs to the `members` layer.
|
|
47
|
+
- **Support symbols as the EduBeam app draws them**, stroke for stroke: a pin is a bare triangle, a roller the
|
|
48
|
+
triangle on its track, a clamp a wall with seven hatch strokes, a slider two hatched rails, and the
|
|
49
|
+
rotation-only support the app's cross with its corner strokes. Supports still turn away from their members.
|
|
50
|
+
- **Reactions as an exercise's unknowns**: `reactionLabels: 'names'` (a `StructurePlot` prop and a
|
|
51
|
+
`structureSvg` option) draws an arrow for every restrained direction, pointing the way it counts as positive
|
|
52
|
+
(along the node's x, up, counter-clockwise), named A_x, A_z and M_A, in italic with real subscripts, instead of sized. It needs
|
|
53
|
+
no results, so an unsolved model can be an exercise sheet. Names are placed before node labels.
|
|
54
|
+
- `reserveReactionLabels` (a prop, a `structureSvg` option and a `layoutStructure` argument) makes room for both
|
|
55
|
+
reaction label styles, so an exercise that turns into its solution keeps its drawing where it is.
|
|
56
|
+
- Labels can carry a subscript (`sub` on scene text), drawn as a smaller, lower `tspan` with a halo of its own.
|
|
57
|
+
- Dimension lines mark each stop with the oblique stroke of a technical drawing.
|
|
58
|
+
- A fixing moment's name at a wall goes up and away from the beam and its loads, and arrow heads keep labels
|
|
59
|
+
off them as their shafts do.
|
|
60
|
+
- **Reactions are bare numbers**, like the diagram values and as the EduBeam app writes them: a figure gives
|
|
61
|
+
units with what is given (loads, settlements, temperature changes), not with results. Before, a reaction read
|
|
62
|
+
"36 kN" next to a moment diagram reading "54".
|
|
63
|
+
- **`structureSvg(model, options)`** writes a plot as a standalone `.svg` file: plain colours (`PRINT_COLORS`,
|
|
64
|
+
or your own), no CSS custom properties, label halos as separate text, so Word, Inkscape, LaTeX tool chains
|
|
65
|
+
and cairosvg draw it as the page does. `layoutStructure` is the shared layout behind it and `StructurePlot`.
|
|
66
|
+
- **Chain dimensions**: the `dimensions` layer gives every span between nodes and point loads along x, and
|
|
67
|
+
every storey along z, with the overall size on a second line, as an exercise sheet does.
|
|
68
|
+
- A load's or a reaction's value is placed before any diagram's numbers, so it can no longer be pushed out
|
|
69
|
+
by the labels of a reserved result (a point load's "20 kN" over a step in V disappeared).
|
|
70
|
+
- A step in V or N over a support shows both its values (the joint rule that writes a rigid corner's moment
|
|
71
|
+
once no longer swallows a shear step of equal size), and a symmetric structure's largest deflection is
|
|
72
|
+
labelled in every span where it occurs.
|
|
73
|
+
- Labels keep off the diagram on show (a load's value moves along its band, a constant diagram's value to a
|
|
74
|
+
quarter point) without the fit ever depending on which diagram that is; curved outlines are followed
|
|
75
|
+
exactly. Node labels clear the arc of a fixing or nodal moment; settlement, nodal moment and reaction
|
|
76
|
+
values have alternative places.
|
|
77
|
+
- Floating-point noise is rounded away before formatting: a reaction of 8749.999… N reads 8.75 kN.
|
|
78
|
+
- `structureSvg` takes `reserve` and `reserveLabelModes`, so the files of a build-up line up as overlays.
|
|
79
|
+
- More types are exported: `TextPlacement`, `ResolveOptions`, `Bounds`, `SceneText`, `ResolvedPath`,
|
|
80
|
+
`ResolvedText`, `ResolvedCircle`.
|
|
81
|
+
- Every non-zero end of a diagram now carries its value, as a textbook labels it; before, a member end was
|
|
82
|
+
numbered only where it was that member's extreme, so e.g. a cantilever's tip shear went unlabelled.
|
|
83
|
+
- The hover readout marks the value where it is drawn: a dot at the tip of each shown diagram's ordinate
|
|
84
|
+
(both tips across a step) or on the deformed shape, joined to the member point. The pointer also picks up
|
|
85
|
+
a member from anywhere over its diagram.
|
|
86
|
+
- Labels of result layers shown one at a time (reserved but hidden) no longer push out the labels of the
|
|
87
|
+
layer on show.
|
|
88
|
+
- A nodal load whose arrow would lie along a member at its node, such as a load at a truss's bottom chord
|
|
89
|
+
under a vertical, hangs off the node on the free side instead.
|
|
90
|
+
- With `animate` off, paths no longer carry the draw-on dash styling at all.
|
|
91
|
+
- `readoutMarks` and `isBarStructure` are exported.
|
|
92
|
+
|
|
5
93
|
## 0.1.0 (2026-11-18)
|
|
6
94
|
|
|
7
95
|
The first release.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type ResultLabelMode } from '../core/structure.js';
|
|
2
1
|
import { type Readout } from '../core/readout.js';
|
|
3
2
|
import type { StructurePlotProps } from './types.js';
|
|
4
3
|
declare const __VLS_export: import("vue").DefineComponent<StructurePlotProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
@@ -8,7 +7,7 @@ declare const __VLS_export: import("vue").DefineComponent<StructurePlotProps, {}
|
|
|
8
7
|
}>, {
|
|
9
8
|
compact: boolean;
|
|
10
9
|
momentOnTensionSide: boolean;
|
|
11
|
-
resultLabelMode: ResultLabelMode;
|
|
10
|
+
resultLabelMode: import("../index.js").ResultLabelMode;
|
|
12
11
|
loadCase: number;
|
|
13
12
|
revision: number;
|
|
14
13
|
padding: number;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The few words the components say for themselves, to screen readers: the figure's accessible name,
|
|
3
|
+
* a diagram stack's, and the movable load's slider. English unless an app provides its own:
|
|
4
|
+
* `app.provide(PLOT_TEXTS, { structure: (layers) => … })`, or a ref of such an object to follow a
|
|
5
|
+
* language switch. A page's `title` prop still wins over `structure`.
|
|
6
|
+
*/
|
|
7
|
+
import { type ComputedRef, type InjectionKey, type Ref } from 'vue';
|
|
8
|
+
import { type PlotLayer, type TemperatureSymbols } from '../core/structure.js';
|
|
9
|
+
export interface PlotTexts {
|
|
10
|
+
/** A structure plot's accessible name, from the layers it shows, in paint order. */
|
|
11
|
+
readonly structure: (shown: readonly PlotLayer[]) => string;
|
|
12
|
+
/** A diagram stack's accessible name, from the rows it shows beneath the beam. */
|
|
13
|
+
readonly stack: (rows: readonly ('N' | 'V' | 'M' | 'w')[]) => string;
|
|
14
|
+
/** The temperature load's symbols drawn on a figure, as the app the figure belongs to writes them. */
|
|
15
|
+
readonly temperature: TemperatureSymbols;
|
|
16
|
+
/** The movable load's slider, named after the load's own label ("20 kN"). */
|
|
17
|
+
readonly loadHandle: (load: string) => string;
|
|
18
|
+
/** The slider's position in words, the distance already formatted ("3.20"). */
|
|
19
|
+
readonly loadPosition: (metres: string) => string;
|
|
20
|
+
}
|
|
21
|
+
export declare const DEFAULT_PLOT_TEXTS: PlotTexts;
|
|
22
|
+
export declare const PLOT_TEXTS: InjectionKey<Partial<PlotTexts> | Ref<Partial<PlotTexts>>>;
|
|
23
|
+
/** The texts in effect: the app's where it gives them, English for the rest. */
|
|
24
|
+
export declare const usePlotTexts: () => ComputedRef<PlotTexts>;
|
|
@@ -9,8 +9,8 @@ export declare const DEFAULT_COLORS: PlotColors;
|
|
|
9
9
|
/** Custom properties for the root element: the defaults, with any colour the caller overrides. */
|
|
10
10
|
export declare const toneVars: (colors?: Partial<PlotColors>) => Record<string, string>;
|
|
11
11
|
/**
|
|
12
|
-
* Inlined into each SVG rather than shipped as a stylesheet, so a plot needs no CSS import
|
|
13
|
-
* the same on the server
|
|
14
|
-
* a page can restyle them, e.g.
|
|
12
|
+
* Inlined into each SVG rather than shipped as a stylesheet, so a plot needs no CSS import and
|
|
13
|
+
* renders the same on the server. Its colours stay CSS custom properties of the page: for a file,
|
|
14
|
+
* use `structureSvg`. Every class is `ebp-` prefixed; a page can restyle them, e.g. the timing.
|
|
15
15
|
*/
|
|
16
16
|
export declare const PLOT_CSS: string;
|
|
@@ -5,11 +5,11 @@ import type { Solver } from '@edubeam/fem';
|
|
|
5
5
|
import type { PlotModel } from '../core/model.js';
|
|
6
6
|
import type { Readout } from '../core/readout.js';
|
|
7
7
|
import type { StackRow } from '../core/stack.js';
|
|
8
|
-
import type { PlotLayer, ResultLabelMode, ResultLayer } from '../core/structure.js';
|
|
8
|
+
import type { PlotLayer, ReactionLabels, ResultLabelMode, ResultLayer } from '../core/structure.js';
|
|
9
9
|
import type { Units } from '../core/units.js';
|
|
10
10
|
import type { PlotColors } from './theme.js';
|
|
11
11
|
export interface StructurePlotProps {
|
|
12
|
-
/**
|
|
12
|
+
/** An @edubeam/fem solver; solved, to show results. Pass a new one (or bump `revision`) after a change. */
|
|
13
13
|
solver?: Solver;
|
|
14
14
|
/** Or the plain data `modelFromSolver` makes, e.g. prepared at build time. */
|
|
15
15
|
model?: PlotModel;
|
|
@@ -41,11 +41,21 @@ export interface StructurePlotProps {
|
|
|
41
41
|
momentOnTensionSide?: boolean;
|
|
42
42
|
/** Values upright, or turned to run along their ordinate across the member (`axis`), as in the app. */
|
|
43
43
|
resultLabelMode?: ResultLabelMode;
|
|
44
|
+
/**
|
|
45
|
+
* `names` draws the reactions as the unknowns of an exercise: an arrow for every restrained
|
|
46
|
+
* direction, pointing the way it counts as positive, named (A with subscript x) instead of sized.
|
|
47
|
+
*/
|
|
48
|
+
reactionLabels?: ReactionLabels;
|
|
44
49
|
/**
|
|
45
50
|
* Label styles to make room for besides the current one, so switching `resultLabelMode` moves
|
|
46
51
|
* only the labels, not the drawing - as `reserve` does for layers.
|
|
47
52
|
*/
|
|
48
53
|
reserveLabelModes?: readonly ResultLabelMode[];
|
|
54
|
+
/**
|
|
55
|
+
* Reaction label styles to make room for besides `reactionLabels`, so an exercise that turns into
|
|
56
|
+
* its solution (`'names'` to `'values'`) keeps its drawing where it is.
|
|
57
|
+
*/
|
|
58
|
+
reserveReactionLabels?: readonly ReactionLabels[];
|
|
49
59
|
/** Fade layers in and draw members on. Always off under prefers-reduced-motion. */
|
|
50
60
|
animate?: boolean;
|
|
51
61
|
/** Read values off the members under the pointer. Off, the plot takes no pointer input at all. */
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Laying a structure out in a box: the one routine behind both `StructurePlot` and `structureSvg`,
|
|
3
|
+
* so a figure on a page and the same figure saved as a file are drawn alike.
|
|
4
|
+
*/
|
|
5
|
+
import type { PlotModel } from './model.js';
|
|
6
|
+
import { type Fit, type FitBox, type ResolvedScene, type SceneItem } from './scene.js';
|
|
7
|
+
import { type PlotLayer, type ReactionLabels, type ResultLabelMode, type StructureSceneOptions } from './structure.js';
|
|
8
|
+
export interface StructureLayout {
|
|
9
|
+
readonly fit: Fit;
|
|
10
|
+
readonly items: readonly SceneItem[];
|
|
11
|
+
readonly resolved: ResolvedScene;
|
|
12
|
+
}
|
|
13
|
+
/** Results shown one at a time make room for each other's labels but never fight over places. */
|
|
14
|
+
export declare const alternativeResultGroups: (shown: ReadonlySet<PlotLayer>) => ReadonlySet<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Fit with every label, see which survive, then fit again on those: a label that is dropped for
|
|
17
|
+
* crowding does not shrink the structure. The last pass may bring back any label that now fits.
|
|
18
|
+
*
|
|
19
|
+
* `options.layers` are the layers laid out (everything that may be shown); `shown` those on show.
|
|
20
|
+
* `labelModes` are the label styles to make room for, so switching between them moves nothing;
|
|
21
|
+
* `reactionLabels` the same for the reactions' names and values (an exercise and its solution).
|
|
22
|
+
*/
|
|
23
|
+
export declare const layoutStructure: (model: PlotModel, options: Omit<StructureSceneOptions, "scale">, box: FitBox, shown?: ReadonlySet<PlotLayer>, labelModes?: readonly ResultLabelMode[], reactionLabels?: readonly ReactionLabels[]) => StructureLayout;
|
package/dist/core/model.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export interface LineIntensity {
|
|
|
31
31
|
}
|
|
32
32
|
export type PlotLoad =
|
|
33
33
|
/** A force at a node, global components, N. */
|
|
34
|
-
{
|
|
34
|
+
({
|
|
35
35
|
readonly kind: 'nodalForce';
|
|
36
36
|
readonly node: string;
|
|
37
37
|
readonly fx: number;
|
|
@@ -80,6 +80,9 @@ export type PlotLoad =
|
|
|
80
80
|
readonly dx?: number;
|
|
81
81
|
readonly dz?: number;
|
|
82
82
|
readonly ry?: number;
|
|
83
|
+
}) & {
|
|
84
|
+
/** Where the caller keeps it, to tell which drawn load is which (the editor's `nodalLoad:3`). */
|
|
85
|
+
readonly source?: string;
|
|
83
86
|
};
|
|
84
87
|
export type PlotLoadKind = PlotLoad['kind'];
|
|
85
88
|
export type ReactionDof = 'dx' | 'dz' | 'ry';
|
|
@@ -24,7 +24,6 @@ export declare const evalPieceSlope: (piece: Piece, x: number) => number;
|
|
|
24
24
|
* right of one - never leaks into the piece: its end values are the one-sided limits.
|
|
25
25
|
*/
|
|
26
26
|
export declare const fitPiece: (f: (x: number) => number, x0: number, x1: number, degree: number) => Piece;
|
|
27
|
-
/** Largest |value| over the pieces, end values and interior extremes included. */
|
|
28
27
|
export declare const maxAbs: (pw: Piecewise) => number;
|
|
29
28
|
/**
|
|
30
29
|
* Drops coefficients below `tolerance`: the round-off a solved structure leaves in a value that is
|
package/dist/core/readout.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* values where a point load or a support makes a step.
|
|
4
4
|
*/
|
|
5
5
|
import { type MemberResults, type PlotModel } from './model.js';
|
|
6
|
-
import { type Transform } from './scene.js';
|
|
6
|
+
import { type Bounds, type Tone, type Transform } from './scene.js';
|
|
7
7
|
import { type Units } from './units.js';
|
|
8
8
|
/** Either side of a point; the two are equal where the result is continuous. */
|
|
9
9
|
export interface SidedValue {
|
|
@@ -19,13 +19,65 @@ export interface Readout {
|
|
|
19
19
|
readonly px: number;
|
|
20
20
|
readonly py: number;
|
|
21
21
|
readonly values: Readonly<Record<ReadoutQuantity, SidedValue>>;
|
|
22
|
+
/** Displacement along the member's local x there, m. */
|
|
23
|
+
readonly u: number;
|
|
22
24
|
}
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The results at x, snapping to a point a reader looks for within `snap` metres: a break, so a step
|
|
27
|
+
* shows both its values, or - given the member's `length` - an end; else an interior extreme of a
|
|
28
|
+
* quantity in `extremaOf`, the largest moment (where the shear is zero) before the largest
|
|
29
|
+
* deflection, then shear and normal force. Within a kind, the nearest.
|
|
30
|
+
*/
|
|
31
|
+
export declare const readMember: (results: MemberResults, x: number, snap?: number, length?: number, extremaOf?: readonly ReadoutQuantity[]) => {
|
|
25
32
|
x: number;
|
|
33
|
+
u: number;
|
|
26
34
|
values: Record<ReadoutQuantity, SidedValue>;
|
|
27
35
|
};
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
/**
|
|
37
|
+
* The member nearest the screen point (px, py), within `reach` px, and its results there, snapped
|
|
38
|
+
* to its steps, its ends and the extremes of the quantities in `extremaOf` (see `readMember`).
|
|
39
|
+
*/
|
|
40
|
+
export declare const readoutAt: (model: PlotModel, t: Transform, px: number, py: number, reach: number, extremaOf?: readonly ReadoutQuantity[]) => Readout | null;
|
|
41
|
+
/** Where a read value sits on the drawing: on its diagram's outline, or on the deformed shape. */
|
|
42
|
+
export interface ReadoutMark {
|
|
43
|
+
readonly tone: Tone;
|
|
44
|
+
/** The member point, px. */
|
|
45
|
+
readonly from: readonly [number, number];
|
|
46
|
+
/** The ordinate's tip (or the displaced point), px. */
|
|
47
|
+
readonly to: readonly [number, number];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The points on the drawn results that a readout's values belong to: the tip of each shown
|
|
51
|
+
* diagram's ordinate (both tips across a step), and the point on the deformed shape. `k` is px
|
|
52
|
+
* per SI unit, `side` the side each diagram is drawn on (see `diagramScales`, `diagramSide`).
|
|
53
|
+
*/
|
|
54
|
+
export declare const readoutMarks: (model: PlotModel, t: Transform, r: Readout, shown: readonly ReadoutQuantity[], k: Readonly<Record<ReadoutQuantity, number>>, side: Readonly<Record<"N" | "V" | "M", 1 | -1>>) => ReadoutMark[];
|
|
55
|
+
/**
|
|
56
|
+
* "M = 54 kNm", or "V = 13.3 → −6.7 kN" across a step. `write`, given a value in display units,
|
|
57
|
+
* writes the number in place of `format` (an editor's own style for displacements, say).
|
|
58
|
+
*/
|
|
59
|
+
export declare const formatReadout: (r: Readout, q: ReadoutQuantity, units: Units, format?: Intl.NumberFormat, write?: (value: number) => string) => string;
|
|
60
|
+
/** A value read off the drawing, as a small tag beside the point it belongs to. */
|
|
61
|
+
export interface ReadoutTag {
|
|
62
|
+
readonly tone: Tone;
|
|
63
|
+
readonly text: string;
|
|
64
|
+
/** The tag's box, px. */
|
|
65
|
+
readonly x: number;
|
|
66
|
+
readonly y: number;
|
|
67
|
+
readonly w: number;
|
|
68
|
+
readonly h: number;
|
|
69
|
+
/** The point it belongs to, px: a diagram's tip, the displaced point, or the member point. */
|
|
70
|
+
readonly at: readonly [number, number];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Each read value as a tag just past the point it belongs to, along that quantity's own ordinate
|
|
74
|
+
* (out from the member), stepping further out only to keep clear of the tags already placed, the
|
|
75
|
+
* member and the pointer. The station's `x` is the last tag, beside the member point on the side
|
|
76
|
+
* the fewest values take. `member` is the member's line on screen, px.
|
|
77
|
+
*/
|
|
78
|
+
export declare const placeReadoutTags: (readings: readonly {
|
|
79
|
+
readonly mark: ReadoutMark;
|
|
80
|
+
readonly text: string;
|
|
81
|
+
}[], caption: string | null, member: readonly [readonly [number, number], readonly [number, number]], pointer: readonly [number, number], fontSize: number,
|
|
82
|
+
/** The visible area, px: a tag that would leave it is put elsewhere */
|
|
83
|
+
viewport?: Bounds) => ReadoutTag[];
|
package/dist/core/scene.d.ts
CHANGED
|
@@ -49,6 +49,11 @@ export type LayerIndex = (typeof LAYERS)[keyof typeof LAYERS];
|
|
|
49
49
|
/** What every item carries: the caller's layer it belongs to, which switches it on and off. */
|
|
50
50
|
interface SceneBase {
|
|
51
51
|
readonly group: string;
|
|
52
|
+
/**
|
|
53
|
+
* What the item draws, for a caller that marks it on hover or selection: `member:<id>`,
|
|
54
|
+
* `node:<id>`, or a load's own `source`. Items of nothing in particular (dimensions) have none.
|
|
55
|
+
*/
|
|
56
|
+
readonly entity?: string;
|
|
52
57
|
}
|
|
53
58
|
export interface ScenePath extends SceneBase {
|
|
54
59
|
readonly kind: 'path';
|
|
@@ -66,8 +71,18 @@ export interface ScenePath extends SceneBase {
|
|
|
66
71
|
readonly cap?: 'round' | 'butt';
|
|
67
72
|
/** A label may not cover this line (the members). */
|
|
68
73
|
readonly obstacle?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Only the labels of other, always-on layers (loads, reactions) may not cover this line: a
|
|
76
|
+
* diagram's outline, which its own numbers sit against.
|
|
77
|
+
*/
|
|
78
|
+
readonly shield?: boolean;
|
|
69
79
|
/** Drawn on from start to end when it appears; the number staggers members one after another. */
|
|
70
80
|
readonly draw?: number;
|
|
81
|
+
/**
|
|
82
|
+
* Not drawn: the area a caller hit-tests the item it belongs to by (a distributed load's band,
|
|
83
|
+
* mostly empty between its arrows). Never an obstacle, never fitted.
|
|
84
|
+
*/
|
|
85
|
+
readonly hitArea?: boolean;
|
|
71
86
|
}
|
|
72
87
|
export type TextAlign = 'start' | 'middle' | 'end';
|
|
73
88
|
export type TextBaseline = 'top' | 'middle' | 'bottom';
|
|
@@ -82,6 +97,11 @@ export interface TextPlacement {
|
|
|
82
97
|
readonly size?: number;
|
|
83
98
|
/** Clockwise turn, degrees. */
|
|
84
99
|
readonly rotate?: number;
|
|
100
|
+
/**
|
|
101
|
+
* The spot may cross another diagram's outline, the label's halo keeping it readable: beside a
|
|
102
|
+
* value at the same point, which is where a reader looks for it, rather than further away.
|
|
103
|
+
*/
|
|
104
|
+
readonly acrossDiagrams?: boolean;
|
|
85
105
|
}
|
|
86
106
|
export interface SceneText extends SceneBase {
|
|
87
107
|
readonly kind: 'text';
|
|
@@ -99,6 +119,10 @@ export interface SceneText extends SceneBase {
|
|
|
99
119
|
readonly weight?: number;
|
|
100
120
|
/** Font size, px; the plot's own when left out. */
|
|
101
121
|
readonly size?: number;
|
|
122
|
+
/** Written after `text`, smaller and lower: the x of A_x. */
|
|
123
|
+
readonly sub?: string;
|
|
124
|
+
/** The place may cross another diagram's outline (see TextPlacement). */
|
|
125
|
+
readonly acrossDiagrams?: boolean;
|
|
102
126
|
/** Other places to try, in order, when the first is taken. */
|
|
103
127
|
readonly alternatives?: readonly TextPlacement[];
|
|
104
128
|
}
|
|
@@ -122,8 +146,12 @@ export interface Transform {
|
|
|
122
146
|
}
|
|
123
147
|
export declare const project: (t: Transform, a: Anchor) => [number, number];
|
|
124
148
|
export declare const textWidth: (text: string, size: number) => number;
|
|
149
|
+
/** A subscript's size, as a share of its text's */
|
|
150
|
+
export declare const SUB_SCALE = 0.75;
|
|
151
|
+
/** How far a subscript drops below the baseline, as a share of its text's size */
|
|
152
|
+
export declare const SUB_DROP = 0.28;
|
|
125
153
|
/** The text's box around its anchor, before any rotation, in px. */
|
|
126
|
-
export declare const textBox: (text: string, size: number, align: TextAlign, baseline: TextBaseline) => {
|
|
154
|
+
export declare const textBox: (text: string, size: number, align: TextAlign, baseline: TextBaseline, sub?: string) => {
|
|
127
155
|
x0: number;
|
|
128
156
|
x1: number;
|
|
129
157
|
y0: number;
|
|
@@ -163,6 +191,7 @@ export interface Fit extends Transform {
|
|
|
163
191
|
export declare const fitScene: (items: readonly SceneItem[], box: FitBox) => Fit;
|
|
164
192
|
export interface ResolvedPath {
|
|
165
193
|
readonly group: string;
|
|
194
|
+
readonly entity?: string;
|
|
166
195
|
readonly d: string;
|
|
167
196
|
readonly layer: LayerIndex;
|
|
168
197
|
readonly tone: Tone;
|
|
@@ -173,9 +202,12 @@ export interface ResolvedPath {
|
|
|
173
202
|
readonly dash?: string;
|
|
174
203
|
readonly cap?: 'round' | 'butt';
|
|
175
204
|
readonly draw?: number;
|
|
205
|
+
/** Not to be drawn: an area to hit-test by (see ScenePath) */
|
|
206
|
+
readonly hitArea?: boolean;
|
|
176
207
|
}
|
|
177
208
|
export interface ResolvedText {
|
|
178
209
|
readonly group: string;
|
|
210
|
+
readonly entity?: string;
|
|
179
211
|
readonly x: number;
|
|
180
212
|
readonly y: number;
|
|
181
213
|
readonly text: string;
|
|
@@ -185,9 +217,11 @@ export interface ResolvedText {
|
|
|
185
217
|
readonly italic?: boolean;
|
|
186
218
|
readonly weight?: number;
|
|
187
219
|
readonly size?: number;
|
|
220
|
+
readonly sub?: string;
|
|
188
221
|
}
|
|
189
222
|
export interface ResolvedCircle {
|
|
190
223
|
readonly group: string;
|
|
224
|
+
readonly entity?: string;
|
|
191
225
|
readonly cx: number;
|
|
192
226
|
readonly cy: number;
|
|
193
227
|
readonly r: number;
|
|
@@ -200,6 +234,11 @@ export interface ResolvedScene {
|
|
|
200
234
|
readonly paths: readonly ResolvedPath[];
|
|
201
235
|
readonly circles: readonly ResolvedCircle[];
|
|
202
236
|
readonly texts: readonly ResolvedText[];
|
|
237
|
+
/**
|
|
238
|
+
* What is painted, px at the transform's scale with no translation: the labels where they were
|
|
239
|
+
* placed (left-out ones not at all), without the fit-ignored hatching and hit areas.
|
|
240
|
+
*/
|
|
241
|
+
readonly bounds: Bounds;
|
|
203
242
|
}
|
|
204
243
|
export declare const pathData: (segments: readonly Segment[], t: Transform) => string;
|
|
205
244
|
/** Whether the segment p–q passes through the box (Liang-Barsky clipping). */
|
|
@@ -213,13 +252,41 @@ export interface ResolveOptions {
|
|
|
213
252
|
};
|
|
214
253
|
/** Labels that must be left out whatever room there is. */
|
|
215
254
|
readonly exclude?: ReadonlySet<SceneText>;
|
|
255
|
+
/**
|
|
256
|
+
* Groups that are never shown together (one result diagram at a time): their labels are placed
|
|
257
|
+
* after everything else and give way to it, but not to each other, so a hidden diagram's numbers
|
|
258
|
+
* never push out a load's value or the numbers of the diagram on show.
|
|
259
|
+
*/
|
|
260
|
+
readonly alternativeGroups?: ReadonlySet<string>;
|
|
261
|
+
/**
|
|
262
|
+
* The groups whose `shield` lines count (the diagrams on show); all of them when left out. A
|
|
263
|
+
* hidden diagram does not keep a load's value off the place it would take.
|
|
264
|
+
*/
|
|
265
|
+
readonly shields?: ReadonlySet<string>;
|
|
266
|
+
/**
|
|
267
|
+
* Groups placed after every other label: the results, read off the structure. The others (loads,
|
|
268
|
+
* reactions, names) are what the reader was given, so they go first. With it, a label that finds
|
|
269
|
+
* no place clear of another diagram's outline may cross it, its halo keeping it readable, rather
|
|
270
|
+
* than be left out. Without it, every group is placed by priority alone.
|
|
271
|
+
*/
|
|
272
|
+
readonly lateGroups?: ReadonlySet<string>;
|
|
273
|
+
/**
|
|
274
|
+
* Groups that give way to every other label: their labels are placed last, and their lines keep
|
|
275
|
+
* no other group's label off (an editor's loads, whose values stand outside their bands while the
|
|
276
|
+
* internal forces' values may lie over a band's side).
|
|
277
|
+
*/
|
|
278
|
+
readonly yieldingGroups?: ReadonlySet<string>;
|
|
279
|
+
/** Groups whose labels are never left out: with no free place, at their first place all the same. */
|
|
280
|
+
readonly keptGroups?: ReadonlySet<string>;
|
|
216
281
|
}
|
|
217
|
-
/**
|
|
218
|
-
* Which labels to draw. By priority, a label is kept unless it would overlap one already kept,
|
|
219
|
-
* cross a member, or leave the viewport - so the figure never shows two numbers on top of each
|
|
220
|
-
* other or a number struck through by the structure.
|
|
221
|
-
*/
|
|
222
282
|
export declare const placeLabels: (items: readonly SceneItem[], t: Transform, options: ResolveOptions) => Map<SceneText, SceneText>;
|
|
223
283
|
/** Screen geometry for the scene, with the labels `placeLabels` keeps. */
|
|
284
|
+
/**
|
|
285
|
+
* The resolved paths with every run that would paint alike - same layer, group, entity and style -
|
|
286
|
+
* joined into one path: a band of thirty arrows becomes two paths (shafts, heads) instead of sixty.
|
|
287
|
+
* Paint order is kept between layers and between different styles; within a layer, alike paths
|
|
288
|
+
* gather where the first of them was. Paths that animate on (`draw`) are left alone.
|
|
289
|
+
*/
|
|
290
|
+
export declare const mergePaths: (paths: readonly ResolvedPath[]) => ResolvedPath[];
|
|
224
291
|
export declare const resolveScene: (items: readonly SceneItem[], t: Transform, options: ResolveOptions) => ResolvedScene;
|
|
225
292
|
export {};
|