@osrd-project/ui-charts 0.0.76 → 0.0.78
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/README.md +22 -19
- package/dist/index.esm.js +194 -66
- package/dist/index.esm.js.map +1 -1
- package/dist/manchette/components/Manchette.d.ts +1 -1
- package/dist/manchette/components/Waypoint.d.ts +5 -3
- package/dist/manchette/hooks/useManchetteWithSpaceTimeChart.d.ts +2 -2
- package/dist/manchette/index.d.ts +2 -2
- package/dist/spaceTimeChart/index.d.ts +1 -0
- package/dist/spaceTimeChart/utils/__tests__/scales.spec.d.ts +1 -0
- package/dist/spaceTimeChart/utils/scales.d.ts +24 -0
- package/dist/speedSpaceChart/components/common/InteractionButtons.d.ts +2 -1
- package/dist/speedSpaceChart/components/common/SettingsPanel.d.ts +2 -1
- package/dist/speedSpaceChart/components/hooks.d.ts +1 -1
- package/dist/theme.css +7 -5
- package/dist/theme.css.map +1 -1
- package/dist/trackOccupancyDiagram/components/layers/OccupancyZonesLayer.d.ts +3 -1
- package/dist/trackOccupancyDiagram/components/types.d.ts +12 -11
- package/dist/trackOccupancyDiagram/index.d.ts +1 -0
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -3,43 +3,48 @@
|
|
|
3
3
|
`ui-charts` is a library of charts and diagrams, designed by the project OSRD.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
|
+
|
|
6
7
|
To install the `ui-charts` package, run the following command in your project directory:
|
|
8
|
+
|
|
7
9
|
```sh
|
|
8
10
|
npm install @osrd-project/ui-charts
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
|
|
12
13
|
## Space Time Chart
|
|
14
|
+
|
|
13
15
|
The `SpaceTimeChart` is a React component designed to visualize train paths on a spacetime chart,
|
|
14
|
-
where the default horizontal axis (Ox) represents time and the default vertical axis (Oy) represents
|
|
15
|
-
(axis can be swapped).
|
|
16
|
+
where the default horizontal axis (Ox) represents time and the default vertical axis (Oy) represents
|
|
17
|
+
space (axis can be swapped).
|
|
16
18
|
|
|
17
19
|
Paths, graduations and labels are rendered on **canvas elements**. For interaction detection, shapes
|
|
18
20
|
are rendered on a separate layer with unique colors using a technique known as **"picking"**.
|
|
19
21
|
|
|
20
|
-
`SpaceTimeChart` is solely responsible for rendering and does not manage any state internally.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
You can have a look at its stories [here](https://openrailassociation.github.io/osrd-ui/?path=/story/spacetimechart-rendering--default-args)
|
|
25
|
-
or [here](https://openrailassociation.github.io/osrd-ui/?path=/story/manchette-with-spacetimechart-rendering--waypoint-menu) with its manchette.
|
|
22
|
+
`SpaceTimeChart` is solely responsible for rendering and does not manage any state internally. All
|
|
23
|
+
state management, including paths, offsets, scales, and zoom levels, must be handled by the parent
|
|
24
|
+
component.
|
|
26
25
|
|
|
26
|
+
You can have a look at its stories
|
|
27
|
+
[here](https://ui.osrd.fr/?path=/story/spacetimechart-rendering--default-args)
|
|
28
|
+
or
|
|
29
|
+
[here](https://ui.osrd.fr/?path=/story/manchette-with-spacetimechart-rendering--waypoint-menu)
|
|
30
|
+
with its manchette.
|
|
27
31
|
|
|
28
32
|
## Speed Space Chart
|
|
29
|
-
The `SpeedSpaceChart` is a React component designed to visualize the speed profile of a train along
|
|
30
|
-
a path.
|
|
31
|
-
It also allow to visualize some data along the path, such as the electrical profiles, the max speed profile,
|
|
32
|
-
the power restrictions, etc.
|
|
33
|
-
|
|
34
|
-
You can have a look at its stories [here](https://openrailassociation.github.io/osrd-ui/?path=/story/trackoccupancydiagram-rendering--track-occupancy-diagram-story-default).
|
|
35
33
|
|
|
34
|
+
The `SpeedSpaceChart` is a React component designed to visualize the speed profile of a train along
|
|
35
|
+
a path. It also allow to visualize some data along the path, such as the electrical profiles, the
|
|
36
|
+
max speed profile, the power restrictions, etc.
|
|
36
37
|
|
|
38
|
+
You can have a look at its stories
|
|
39
|
+
[here](https://ui.osrd.fr/?path=/story/trackoccupancydiagram-rendering--track-occupancy-diagram-story-default).
|
|
37
40
|
|
|
38
41
|
## Track Occupancy Diagram
|
|
39
|
-
The `TrackOccupancyDiagram` is a React component designed to visualize the track occupancy in station.
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
The `TrackOccupancyDiagram` is a React component designed to visualize the track occupancy in
|
|
44
|
+
station.
|
|
42
45
|
|
|
46
|
+
You can have a look at its story
|
|
47
|
+
[here](https://ui.osrd.fr/?path=/story/trackoccupancydiagram-rendering--track-occupancy-diagram-story-default).
|
|
43
48
|
|
|
44
49
|
## Resources
|
|
45
50
|
|
|
@@ -50,13 +55,11 @@ There are multiple places to get information on how to do things with `ui-charts
|
|
|
50
55
|
- **Unit Tests**: Refer to `src/__tests__` for practical demonstrations of helper functions from the
|
|
51
56
|
`src/utils` folder.
|
|
52
57
|
|
|
53
|
-
|
|
54
58
|
## Contributing
|
|
55
59
|
|
|
56
60
|
Contributions are welcome! Please refer to the repository's main README.md and CODE_OF_CONDUCT.md
|
|
57
61
|
for more details on how to contribute.
|
|
58
62
|
|
|
59
|
-
|
|
60
63
|
## License
|
|
61
64
|
|
|
62
65
|
This project is licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - see
|
package/dist/index.esm.js
CHANGED
|
@@ -1279,6 +1279,7 @@ function validateTheme({ breakpoints, timeRanges, timeCaptionsStyles, timeCaptio
|
|
|
1279
1279
|
throw new Error(`${PREFIX}: there should be a timeGraduationsStyles for value 1.`);
|
|
1280
1280
|
}
|
|
1281
1281
|
|
|
1282
|
+
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
1282
1283
|
/**
|
|
1283
1284
|
* This function helps to index a sequence of consecutive scales into a binary tree, to make it
|
|
1284
1285
|
* faster to find which scale contains any given position.
|
|
@@ -1493,10 +1494,37 @@ function getSpaceBreakpoints(from, to, tree) {
|
|
|
1493
1494
|
}
|
|
1494
1495
|
return res;
|
|
1495
1496
|
}
|
|
1497
|
+
/**
|
|
1498
|
+
* in most cases, after the rectangle zoom, the screen will be centered
|
|
1499
|
+
* on the center of the rectangle the user drew.
|
|
1500
|
+
* In case we reach max zoom, not to break this expectation we need a different offset calculation
|
|
1501
|
+
*/
|
|
1502
|
+
function computeRectZoomOffsets({ rect, timeOrigin, spaceOrigin, newTimeScale, newSpaceScale, swapAxes, chartWidth, chartHeight, }) {
|
|
1503
|
+
const chartTimeSizePx = !swapAxes ? chartWidth : chartHeight;
|
|
1504
|
+
const chartSpaceSizePx = !swapAxes ? chartHeight : chartWidth;
|
|
1505
|
+
const timeOffset = sideOffset(timeOrigin, newTimeScale, rect.timeStart, rect.timeEnd, chartTimeSizePx);
|
|
1506
|
+
const spaceOffset = sideOffset(spaceOrigin, newSpaceScale, rect.spaceStart, rect.spaceEnd, chartSpaceSizePx);
|
|
1507
|
+
return !swapAxes
|
|
1508
|
+
? { xOffset: timeOffset, yOffset: spaceOffset }
|
|
1509
|
+
: { xOffset: spaceOffset, yOffset: timeOffset };
|
|
1510
|
+
}
|
|
1511
|
+
function sideOffset(origin, newScale, rectStart, rectEnd, chartSideSizePx, axisPadding = 0) {
|
|
1512
|
+
const rectCenter = (Number(rectStart) + Number(rectEnd)) / 2;
|
|
1513
|
+
const newChartSize = chartSideSizePx * newScale;
|
|
1514
|
+
// newChartBorder is the x or y origin after zoom
|
|
1515
|
+
// it’s normally the same as rectStart (the left or top most part of the rectangle)
|
|
1516
|
+
// but if we reach max zoom we can’t use rectStart as the chart displayed origin
|
|
1517
|
+
// because it doesn’t garentees that the zoom rectangle stays exactly at the center of the chart after the zoom
|
|
1518
|
+
const newChartBorder = rectCenter - newChartSize / 2;
|
|
1519
|
+
return (origin - newChartBorder) / newScale - axisPadding * 2;
|
|
1520
|
+
}
|
|
1496
1521
|
|
|
1497
1522
|
const DEFAULT_PICKING_TOLERANCE = 5;
|
|
1498
1523
|
const PAUSE_THICKNESS = 7;
|
|
1499
1524
|
const PAUSE_OPACITY = 0.2;
|
|
1525
|
+
const CIRCLE_RADIUS = 4;
|
|
1526
|
+
const VERTICAL_LINE_HEIGHT = 18;
|
|
1527
|
+
const TEXT_PADDING = 3;
|
|
1500
1528
|
function isPointPickingElement(element) {
|
|
1501
1529
|
return element.type === 'point';
|
|
1502
1530
|
}
|
|
@@ -1536,8 +1564,8 @@ const PathLayer = ({ path, color, level = DEFAULT_LEVEL, pickingTolerance = DEFA
|
|
|
1536
1564
|
/**
|
|
1537
1565
|
* This function returns the list of points to join to draw the path. As it can be discontinuous,
|
|
1538
1566
|
* it is returned as a Point[][]. For now, the only case for discontinuous paths is when the path
|
|
1539
|
-
* stops on a flat step (in which case, we assume the path will be drawn differently
|
|
1540
|
-
* step layer).
|
|
1567
|
+
* stops on or crosses a flat step (in which case, we assume the path will be drawn differently
|
|
1568
|
+
* in the flat step layer).
|
|
1541
1569
|
*
|
|
1542
1570
|
* It will be both used to render the visible path, and the segments on the picking layer.
|
|
1543
1571
|
*/
|
|
@@ -1651,6 +1679,32 @@ const PathLayer = ({ path, color, level = DEFAULT_LEVEL, pickingTolerance = DEFA
|
|
|
1651
1679
|
}
|
|
1652
1680
|
});
|
|
1653
1681
|
}, [path]);
|
|
1682
|
+
/**
|
|
1683
|
+
* This function draws the label with a background.
|
|
1684
|
+
* It is used to draw the label of the path or single point, with a background to make it more readable.
|
|
1685
|
+
*/
|
|
1686
|
+
const drawLabelWithBackground = useCallback((ctx, text, x, y, { textColor, background, fontSize, fontFamily, padding = TEXT_PADDING, alpha = 0.75, }) => {
|
|
1687
|
+
ctx.save();
|
|
1688
|
+
ctx.font = `${fontSize}px ${fontFamily}`;
|
|
1689
|
+
const measure = ctx.measureText(text);
|
|
1690
|
+
const left = measure.actualBoundingBoxLeft;
|
|
1691
|
+
const right = measure.actualBoundingBoxRight;
|
|
1692
|
+
const ascent = measure.actualBoundingBoxAscent;
|
|
1693
|
+
const descent = measure.actualBoundingBoxDescent;
|
|
1694
|
+
const w = left + right + 2 * padding;
|
|
1695
|
+
const h = ascent + descent + 2 * padding;
|
|
1696
|
+
const rx = x - left - padding;
|
|
1697
|
+
const ry = y - ascent - padding;
|
|
1698
|
+
// BACKGROUND
|
|
1699
|
+
ctx.globalAlpha = alpha;
|
|
1700
|
+
ctx.fillStyle = background;
|
|
1701
|
+
ctx.fillRect(rx, ry, w, h);
|
|
1702
|
+
// TEXT
|
|
1703
|
+
ctx.globalAlpha = 1;
|
|
1704
|
+
ctx.fillStyle = textColor;
|
|
1705
|
+
ctx.fillText(text, x, y);
|
|
1706
|
+
ctx.restore();
|
|
1707
|
+
}, []);
|
|
1654
1708
|
/**
|
|
1655
1709
|
* This function draws the label of the path.
|
|
1656
1710
|
*/
|
|
@@ -1694,23 +1748,21 @@ const PathLayer = ({ path, color, level = DEFAULT_LEVEL, pickingTolerance = DEFA
|
|
|
1694
1748
|
ctx.save();
|
|
1695
1749
|
ctx.translate(position.x, position.y);
|
|
1696
1750
|
ctx.rotate(angle);
|
|
1697
|
-
ctx.font = `${fontSize}px ${fontFamily}`;
|
|
1698
1751
|
ctx.textAlign = 'start';
|
|
1699
1752
|
const padding = 2;
|
|
1700
1753
|
const measure = ctx.measureText(label);
|
|
1701
1754
|
const w = measure.width + 2 * padding;
|
|
1702
|
-
const actualBoundingBoxHeight = measure.actualBoundingBoxAscent + measure.actualBoundingBoxDescent;
|
|
1703
|
-
const h = actualBoundingBoxHeight + 2 * padding;
|
|
1704
1755
|
const dx = w < pathLength ? 5 : (pathLength - w) / 2; // Progressively center the label if the path is shorter than the label
|
|
1705
1756
|
const dy = angle >= 0 ? -5 : 15;
|
|
1706
|
-
ctx
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1757
|
+
drawLabelWithBackground(ctx, label, dx, dy, {
|
|
1758
|
+
fontSize,
|
|
1759
|
+
fontFamily,
|
|
1760
|
+
textColor: labelColor,
|
|
1761
|
+
background,
|
|
1762
|
+
padding,
|
|
1763
|
+
});
|
|
1712
1764
|
ctx.restore();
|
|
1713
|
-
}, []);
|
|
1765
|
+
}, [drawLabelWithBackground]);
|
|
1714
1766
|
/**
|
|
1715
1767
|
* This function draws the extremities of the path.
|
|
1716
1768
|
*/
|
|
@@ -1779,7 +1831,41 @@ const PathLayer = ({ path, color, level = DEFAULT_LEVEL, pickingTolerance = DEFA
|
|
|
1779
1831
|
drawLines(totalPathWidth, backgroundColor);
|
|
1780
1832
|
ctx.restore();
|
|
1781
1833
|
}, [border, getPathLines, level]);
|
|
1834
|
+
const drawSinglePoint = useCallback((ctx, stcContext, point) => {
|
|
1835
|
+
const { getPoint, hidePathsLabels, theme: { background, pathsStyles: { fontSize, fontFamily }, }, } = stcContext;
|
|
1836
|
+
const { x, y } = getPoint(point);
|
|
1837
|
+
const style = STYLES[level];
|
|
1838
|
+
ctx.save();
|
|
1839
|
+
ctx.strokeStyle = color;
|
|
1840
|
+
ctx.lineWidth = style.width;
|
|
1841
|
+
ctx.setLineDash((style.dashArray || []).map((v) => v / 2));
|
|
1842
|
+
// Draw the vertical lines above and below the circle
|
|
1843
|
+
ctx.beginPath();
|
|
1844
|
+
ctx.moveTo(x, y - VERTICAL_LINE_HEIGHT / 2);
|
|
1845
|
+
ctx.lineTo(x, y + VERTICAL_LINE_HEIGHT / 2);
|
|
1846
|
+
ctx.stroke();
|
|
1847
|
+
// Draw the circle
|
|
1848
|
+
ctx.beginPath();
|
|
1849
|
+
ctx.arc(x, y, CIRCLE_RADIUS, 0, Math.PI * 2);
|
|
1850
|
+
ctx.stroke();
|
|
1851
|
+
// Draw the label
|
|
1852
|
+
if (!hidePathsLabels) {
|
|
1853
|
+
ctx.textAlign = 'center';
|
|
1854
|
+
const labelY = y - CIRCLE_RADIUS - VERTICAL_LINE_HEIGHT - TEXT_PADDING;
|
|
1855
|
+
drawLabelWithBackground(ctx, path.label, x, labelY, {
|
|
1856
|
+
fontFamily,
|
|
1857
|
+
fontSize,
|
|
1858
|
+
textColor: color,
|
|
1859
|
+
background,
|
|
1860
|
+
});
|
|
1861
|
+
}
|
|
1862
|
+
ctx.restore();
|
|
1863
|
+
}, [level, color, drawLabelWithBackground, path.label]);
|
|
1782
1864
|
const drawAll = useCallback((ctx, stcContext) => {
|
|
1865
|
+
if (path.points.length === 1) {
|
|
1866
|
+
drawSinglePoint(ctx, stcContext, path.points[0]);
|
|
1867
|
+
return;
|
|
1868
|
+
}
|
|
1783
1869
|
drawBorder(ctx, stcContext);
|
|
1784
1870
|
// Draw stops:
|
|
1785
1871
|
ctx.strokeStyle = color;
|
|
@@ -1820,19 +1906,32 @@ const PathLayer = ({ path, color, level = DEFAULT_LEVEL, pickingTolerance = DEFA
|
|
|
1820
1906
|
drawLabel(ctx, stcContext, path.label, color, flatten(lines), pathLength);
|
|
1821
1907
|
}
|
|
1822
1908
|
}, [
|
|
1909
|
+
path.points,
|
|
1910
|
+
path.label,
|
|
1911
|
+
drawBorder,
|
|
1823
1912
|
color,
|
|
1824
1913
|
drawPauses,
|
|
1825
1914
|
level,
|
|
1826
1915
|
getPathLines,
|
|
1827
1916
|
drawExtremities,
|
|
1917
|
+
drawSinglePoint,
|
|
1828
1918
|
computePathLength,
|
|
1829
1919
|
drawLabel,
|
|
1830
|
-
drawBorder,
|
|
1831
|
-
path.label,
|
|
1832
1920
|
]);
|
|
1833
1921
|
useDraw('paths', drawAll);
|
|
1834
1922
|
const drawPicking = useCallback((imageData, stcContext, scalingRatio) => {
|
|
1835
1923
|
const { registerPickingElement } = stcContext;
|
|
1924
|
+
// Draw single point:
|
|
1925
|
+
if (path.points.length === 1) {
|
|
1926
|
+
const pickingElement = {
|
|
1927
|
+
type: 'point',
|
|
1928
|
+
pathId: path.id,
|
|
1929
|
+
point: stcContext.getPoint(path.points[0]),
|
|
1930
|
+
};
|
|
1931
|
+
const index = registerPickingElement(pickingElement);
|
|
1932
|
+
const pointColor = hexToRgb(indexToColor(index));
|
|
1933
|
+
drawAliasedDisc(imageData, pickingElement.point, VERTICAL_LINE_HEIGHT / 2, pointColor, false, scalingRatio);
|
|
1934
|
+
}
|
|
1836
1935
|
// Draw segments:
|
|
1837
1936
|
getPathLines(stcContext).forEach((line) => line.forEach((point, i, a) => {
|
|
1838
1937
|
if (i) {
|
|
@@ -1845,6 +1944,10 @@ const PathLayer = ({ path, color, level = DEFAULT_LEVEL, pickingTolerance = DEFA
|
|
|
1845
1944
|
};
|
|
1846
1945
|
const index = registerPickingElement(pickingElement);
|
|
1847
1946
|
const lineColor = hexToRgb(indexToColor(index));
|
|
1947
|
+
// Skip segments linking two points on the same time value (these are flat steps, and paths shouldn't be
|
|
1948
|
+
// actionable on these steps):
|
|
1949
|
+
if (previousPoint[stcContext.timeAxis] === point[stcContext.timeAxis])
|
|
1950
|
+
return;
|
|
1848
1951
|
drawAliasedLine(imageData, previousPoint, point, lineColor, STYLES[level].width + pickingTolerance, true, scalingRatio);
|
|
1849
1952
|
}
|
|
1850
1953
|
}));
|
|
@@ -1859,7 +1962,7 @@ const PathLayer = ({ path, color, level = DEFAULT_LEVEL, pickingTolerance = DEFA
|
|
|
1859
1962
|
const lineColor = hexToRgb(indexToColor(index));
|
|
1860
1963
|
drawAliasedDisc(imageData, point, (STYLES[level].width + pickingTolerance) * 2, lineColor, false, scalingRatio);
|
|
1861
1964
|
});
|
|
1862
|
-
}, [getPathLines, getSnapPoints, level, path.id, pickingTolerance]);
|
|
1965
|
+
}, [getPathLines, getSnapPoints, level, path.id, path.points, pickingTolerance]);
|
|
1863
1966
|
usePicking('paths', drawPicking);
|
|
1864
1967
|
return null;
|
|
1865
1968
|
};
|
|
@@ -2527,13 +2630,12 @@ const useManchetteWithSpaceTimeChart = ({ waypoints, manchetteWithSpaceTimeChart
|
|
|
2527
2630
|
const { minZoomMillimeterPerPx, maxZoomMillimeterPerPx } = getExtremaScales(drawingHeightWithoutTopPadding, drawingHeightWithoutBothPadding, totalDistance);
|
|
2528
2631
|
const handleRectangleZoom = useCallback(({ scales: { chosenTimeScale, chosenSpaceScale }, overrideState, }) => {
|
|
2529
2632
|
setState((prev) => {
|
|
2530
|
-
if (prev.zoomMode || !prev.rect) {
|
|
2633
|
+
if (prev.zoomMode || !prev.rect || !spaceTimeChartRef?.current) {
|
|
2531
2634
|
return prev;
|
|
2532
2635
|
}
|
|
2533
2636
|
const newTimeScale = clamp$1(chosenTimeScale, MAX_ZOOM_MS_PER_PX, MIN_ZOOM_MS_PER_PX);
|
|
2534
2637
|
const timeZoomValue = timeScaleToZoomValue(newTimeScale);
|
|
2535
|
-
const
|
|
2536
|
-
const newXOffset = (timeOrigin - leftRectSide) / newTimeScale;
|
|
2638
|
+
const newXOffset = sideOffset(timeOrigin, newTimeScale, prev.rect.timeStart, prev.rect.timeEnd, spaceTimeChartRef.current.clientWidth);
|
|
2537
2639
|
let newYZoom = yZoom;
|
|
2538
2640
|
let newYOffset = yOffset;
|
|
2539
2641
|
if (chosenSpaceScale) {
|
|
@@ -2544,8 +2646,7 @@ const useManchetteWithSpaceTimeChart = ({ waypoints, manchetteWithSpaceTimeChart
|
|
|
2544
2646
|
// that would actually zoom OUT if it wasn’t clamped.
|
|
2545
2647
|
if (newSpaceScale !== minZoomMillimeterPerPx) {
|
|
2546
2648
|
newYZoom = spaceScaleToZoomValue(minZoomMillimeterPerPx, maxZoomMillimeterPerPx, newSpaceScale);
|
|
2547
|
-
|
|
2548
|
-
newYOffset = Math.abs(spaceOrigin - topRectSide) / newSpaceScale;
|
|
2649
|
+
newYOffset = Math.abs(sideOffset(spaceOrigin, newSpaceScale, prev.rect.spaceStart, prev.rect.spaceEnd, height, verticalPadding));
|
|
2549
2650
|
}
|
|
2550
2651
|
}
|
|
2551
2652
|
return {
|
|
@@ -2558,7 +2659,17 @@ const useManchetteWithSpaceTimeChart = ({ waypoints, manchetteWithSpaceTimeChart
|
|
|
2558
2659
|
...overrideState,
|
|
2559
2660
|
};
|
|
2560
2661
|
});
|
|
2561
|
-
}, [
|
|
2662
|
+
}, [
|
|
2663
|
+
timeOrigin,
|
|
2664
|
+
spaceOrigin,
|
|
2665
|
+
minZoomMillimeterPerPx,
|
|
2666
|
+
maxZoomMillimeterPerPx,
|
|
2667
|
+
yOffset,
|
|
2668
|
+
yZoom,
|
|
2669
|
+
height,
|
|
2670
|
+
spaceTimeChartRef,
|
|
2671
|
+
verticalPadding,
|
|
2672
|
+
]);
|
|
2562
2673
|
useEffect(() => {
|
|
2563
2674
|
if (rect && !zoomMode && spaceTimeChartRef?.current) {
|
|
2564
2675
|
const { timeStart, timeEnd, spaceStart, spaceEnd } = rect;
|
|
@@ -3012,17 +3123,17 @@ const ManchetteWithSpaceTimeChart = ({ waypoints, projectPathTrainResult, height
|
|
|
3012
3123
|
children)))));
|
|
3013
3124
|
};
|
|
3014
3125
|
|
|
3015
|
-
const InteractionButtons = ({ reset, openSettingsPanel, store }) => (React.createElement("div", { id: "interaction-button-container", className: "z-10" },
|
|
3126
|
+
const InteractionButtons = ({ reset, openSettingsPanel, store, testIdPrefix, }) => (React.createElement("div", { id: "interaction-button-container", className: "z-10" },
|
|
3016
3127
|
React.createElement("div", { className: "zoom-buttons" },
|
|
3017
3128
|
React.createElement("button", { className: cx('interaction-button reset-button', {
|
|
3018
3129
|
inactive: store.ratioX == 1 && store.leftOffset == 0,
|
|
3019
|
-
}), onClick: () => reset() },
|
|
3130
|
+
}), onClick: () => reset(), "data-testid": testIdPrefix ? `${testIdPrefix}-reset` : undefined },
|
|
3020
3131
|
React.createElement(Iterations, null)),
|
|
3021
|
-
React.createElement("button", { className: "interaction-button plus-button inactive" },
|
|
3132
|
+
React.createElement("button", { className: "interaction-button plus-button inactive", "data-testid": testIdPrefix ? `${testIdPrefix}-zoom-in` : undefined },
|
|
3022
3133
|
React.createElement(Plus, null)),
|
|
3023
|
-
React.createElement("button", { className: "interaction-button inactive" },
|
|
3134
|
+
React.createElement("button", { className: "interaction-button inactive", "data-testid": testIdPrefix ? `${testIdPrefix}-zoom-out` : undefined },
|
|
3024
3135
|
React.createElement(Dash, null))),
|
|
3025
|
-
React.createElement("button", { className: "interaction-button elipsis-button", onClick: () => openSettingsPanel() },
|
|
3136
|
+
React.createElement("button", { className: "interaction-button elipsis-button", "data-testid": testIdPrefix ? `${testIdPrefix}-settings` : undefined, onClick: () => openSettingsPanel() },
|
|
3026
3137
|
React.createElement(KebabHorizontal, null))));
|
|
3027
3138
|
|
|
3028
3139
|
const SLOPE_FILL_COLOR = '#CFDDCE';
|
|
@@ -3386,7 +3497,7 @@ const getSnappedStop = (cursorX, width, store) => {
|
|
|
3386
3497
|
|
|
3387
3498
|
const SETTINGS_PANEL_BASE_HEIGHT = 442;
|
|
3388
3499
|
const SPEEDSPACECHART_BASE_HEIGHT = 521.5;
|
|
3389
|
-
const SettingsPanel = ({ globalHeight, color, store, setStore, setIsMouseHoveringSettingsPanel, translations, }) => {
|
|
3500
|
+
const SettingsPanel = ({ globalHeight, color, store, setStore, setIsMouseHoveringSettingsPanel, translations, testIdPrefix, }) => {
|
|
3390
3501
|
const [height, setHeight] = useState(`${SETTINGS_PANEL_BASE_HEIGHT}px`);
|
|
3391
3502
|
const closeSettingsPanel = () => {
|
|
3392
3503
|
setIsMouseHoveringSettingsPanel(false);
|
|
@@ -3406,7 +3517,7 @@ const SettingsPanel = ({ globalHeight, color, store, setStore, setIsMouseHoverin
|
|
|
3406
3517
|
React.createElement("div", { className: "settings-panel-section-title" },
|
|
3407
3518
|
React.createElement("span", null, translations?.layersDisplay.context || 'Context')),
|
|
3408
3519
|
LAYERS_SELECTION.map((selection) => (React.createElement("div", { key: selection, className: "selection" },
|
|
3409
|
-
React.createElement(Checkbox, { label: translations?.layersDisplay[selection] || selection, checked: store.layersDisplay[selection], disabled: !isLayerActive(store, selection), onChange: () => {
|
|
3520
|
+
React.createElement(Checkbox, { "data-testid": testIdPrefix ? `${testIdPrefix}-layer-${selection}` : undefined, label: translations?.layersDisplay[selection] || selection, checked: store.layersDisplay[selection], disabled: !isLayerActive(store, selection), onChange: () => {
|
|
3410
3521
|
setStore((prev) => ({
|
|
3411
3522
|
...prev,
|
|
3412
3523
|
layersDisplay: {
|
|
@@ -3428,7 +3539,7 @@ const SettingsPanel = ({ globalHeight, color, store, setStore, setIsMouseHoverin
|
|
|
3428
3539
|
},
|
|
3429
3540
|
}));
|
|
3430
3541
|
} }))))),
|
|
3431
|
-
React.createElement("button", { id: "close-settings-panel", onClick: () => closeSettingsPanel() },
|
|
3542
|
+
React.createElement("button", { id: "close-settings-panel", "data-testid": testIdPrefix ? `${testIdPrefix}-close` : undefined, onClick: () => closeSettingsPanel() },
|
|
3432
3543
|
React.createElement("span", null,
|
|
3433
3544
|
React.createElement(X, null)))));
|
|
3434
3545
|
};
|
|
@@ -4361,7 +4472,7 @@ const TOOLTIP_HEIGHT = 40;
|
|
|
4361
4472
|
const MARGIN_ADJUSTMENT = 2;
|
|
4362
4473
|
const SpeedLimitTagsLayer = ({ width, marginTop, store }) => {
|
|
4363
4474
|
const canvas = useRef(null);
|
|
4364
|
-
const tooltip = useRef();
|
|
4475
|
+
const tooltip = useRef(null);
|
|
4365
4476
|
const [images, setImages] = useState({ questionImage: null, alertFillImage: null });
|
|
4366
4477
|
useEffect(() => {
|
|
4367
4478
|
const fetchImages = async () => {
|
|
@@ -4714,9 +4825,9 @@ const SpeedSpaceChart = ({ width, height, backgroundColor, data, setHeight, tran
|
|
|
4714
4825
|
backgroundColor: `${backgroundColor}`,
|
|
4715
4826
|
}, tabIndex: 0 },
|
|
4716
4827
|
React.createElement("div", { className: "flex justify-end absolute base-margin-top", style: { width: adjustedWidthRightAxis } },
|
|
4717
|
-
React.createElement(InteractionButtons, { reset: reset, openSettingsPanel: openSettingsPanel, store: store })),
|
|
4828
|
+
React.createElement(InteractionButtons, { reset: reset, openSettingsPanel: openSettingsPanel, store: store, testIdPrefix: "interaction" })),
|
|
4718
4829
|
store.isSettingsPanelOpened && (React.createElement("div", { className: "flex justify-end absolute ml-2 base-margin-top", style: { width: adjustedWidthRightAxis } },
|
|
4719
|
-
React.createElement(SettingsPanel, { globalHeight: dynamicHeight, color: backgroundColor, store: store, setStore: setStore, setIsMouseHoveringSettingsPanel: setIsMouseHoveringSettingsPanel, translations: translations }))),
|
|
4830
|
+
React.createElement(SettingsPanel, { globalHeight: dynamicHeight, color: backgroundColor, store: store, setStore: setStore, setIsMouseHoveringSettingsPanel: setIsMouseHoveringSettingsPanel, translations: translations, testIdPrefix: "settings-panel" }))),
|
|
4720
4831
|
store.layersDisplay.declivities && (React.createElement(DeclivityLayer, { width: WIDTH_OFFSET, height: HEIGHT_OFFSET, store: store })),
|
|
4721
4832
|
React.createElement(CurveLayer, { width: WIDTH_OFFSET, height: HEIGHT_OFFSET, store: store }),
|
|
4722
4833
|
store.layersDisplay.speedLimits && (React.createElement(SpeedLimitsLayer, { width: adjustedWidthRightAxis, height: height, store: store })),
|
|
@@ -4846,7 +4957,7 @@ const drawOccupancyZonesTexts = ({ ctx, zone, arrivalTimePixel, departureTimePix
|
|
|
4846
4957
|
ctx.font = '400 10px IBM Plex Mono';
|
|
4847
4958
|
const originTextLength = ctx.measureText(zone.originStation || '--').width;
|
|
4848
4959
|
ctx.font = '400 12px IBM Plex Mono';
|
|
4849
|
-
const nameTextLength = ctx.measureText(zone.
|
|
4960
|
+
const nameTextLength = ctx.measureText(zone.trainName).width;
|
|
4850
4961
|
const { xOriginTrainName, yOriginTrainName } = isBelowBreakpoint('medium')
|
|
4851
4962
|
? {
|
|
4852
4963
|
xOriginTrainName: arrivalTimePixel -
|
|
@@ -4887,7 +4998,7 @@ const drawOccupancyZonesTexts = ({ ctx, zone, arrivalTimePixel, departureTimePix
|
|
|
4887
4998
|
}
|
|
4888
4999
|
drawText({
|
|
4889
5000
|
ctx,
|
|
4890
|
-
text: zone.
|
|
5001
|
+
text: zone.trainName,
|
|
4891
5002
|
x: xOriginTrainName,
|
|
4892
5003
|
y: yOriginTrainName,
|
|
4893
5004
|
color: GREY_50,
|
|
@@ -4900,7 +5011,7 @@ const drawOccupancyZonesTexts = ({ ctx, zone, arrivalTimePixel, departureTimePix
|
|
|
4900
5011
|
// arrival minutes & departure minutes
|
|
4901
5012
|
drawText({
|
|
4902
5013
|
ctx,
|
|
4903
|
-
text: new Date(zone.
|
|
5014
|
+
text: new Date(zone.startTime)
|
|
4904
5015
|
.getMinutes()
|
|
4905
5016
|
.toLocaleString('fr-FR', { minimumIntegerDigits: 2 }),
|
|
4906
5017
|
x: isThroughTrain ? arrivalTimePixel - X_THROUGHTRAIN_OFFSET : arrivalTimePixel,
|
|
@@ -4914,7 +5025,7 @@ const drawOccupancyZonesTexts = ({ ctx, zone, arrivalTimePixel, departureTimePix
|
|
|
4914
5025
|
if (!isThroughTrain)
|
|
4915
5026
|
drawText({
|
|
4916
5027
|
ctx,
|
|
4917
|
-
text: new Date(zone.
|
|
5028
|
+
text: new Date(zone.endTime)
|
|
4918
5029
|
.getMinutes()
|
|
4919
5030
|
.toLocaleString('fr-FR', { minimumIntegerDigits: 2 }),
|
|
4920
5031
|
x: departureTimePixel,
|
|
@@ -4959,6 +5070,7 @@ const X_BACKGROUND_PADDING = 4;
|
|
|
4959
5070
|
const X_TROUGHTRAIN_BACKGROUND_PADDING = 8;
|
|
4960
5071
|
const BACKGROUND_HEIGHT = 40;
|
|
4961
5072
|
const SELECTED_TRAIN_ID_GRADIANT = 2;
|
|
5073
|
+
const PATH_SIZE_DEFAULT = 1;
|
|
4962
5074
|
const drawDefaultZone = (ctx, { x, y, width }) => {
|
|
4963
5075
|
ctx.beginPath();
|
|
4964
5076
|
ctx.rect(x, y, width, OCCUPANCY_ZONE_HEIGHT);
|
|
@@ -5008,8 +5120,10 @@ const drawRemainingTrainsBox = (ctx, { getTimePixel, getSpacePixel }, { time, po
|
|
|
5008
5120
|
ctx.fillText(`+${remainingTrainsNb} trains`, x, textY + REMAINING_TRAINS_HEIGHT / 2);
|
|
5009
5121
|
};
|
|
5010
5122
|
const drawOccupationZone = (ctx, stcContext, { zone, yOffset, position, isSelected, }) => {
|
|
5011
|
-
const
|
|
5012
|
-
|
|
5123
|
+
const size = zone.size || PATH_SIZE_DEFAULT;
|
|
5124
|
+
const color = zone.color || PATH_COLOR_DEFAULT;
|
|
5125
|
+
const isThroughTrain = zone.startTime === zone.endTime;
|
|
5126
|
+
ctx.fillStyle = color;
|
|
5013
5127
|
ctx.strokeStyle = WHITE_100$1;
|
|
5014
5128
|
ctx.lineJoin = 'round';
|
|
5015
5129
|
ctx.lineCap = 'round';
|
|
@@ -5018,8 +5132,8 @@ const drawOccupationZone = (ctx, stcContext, { zone, yOffset, position, isSelect
|
|
|
5018
5132
|
const yStart = getCrispLineCoordinate(getSpacePixel(position), BACKGROUND_HEIGHT);
|
|
5019
5133
|
const y = yStart + yOffset;
|
|
5020
5134
|
const yEnd = getSpacePixel(position, true);
|
|
5021
|
-
const arrivalTimePixel = getTimePixel(zone.
|
|
5022
|
-
const departureTimePixel = getTimePixel(zone.
|
|
5135
|
+
const arrivalTimePixel = getTimePixel(zone.startTime);
|
|
5136
|
+
const departureTimePixel = getTimePixel(zone.endTime);
|
|
5023
5137
|
if (isSelected) {
|
|
5024
5138
|
const extraWidth = isThroughTrain ? X_TROUGHTRAIN_BACKGROUND_PADDING : X_BACKGROUND_PADDING;
|
|
5025
5139
|
const originTextLength = ctx.measureText(zone.originStation || '--').width;
|
|
@@ -5033,7 +5147,7 @@ const drawOccupationZone = (ctx, stcContext, { zone, yOffset, position, isSelect
|
|
|
5033
5147
|
extraWidth * 2, BACKGROUND_HEIGHT, SELECTED_TRAIN_ID_GRADIANT);
|
|
5034
5148
|
ctx.fill();
|
|
5035
5149
|
}
|
|
5036
|
-
ctx.fillStyle =
|
|
5150
|
+
ctx.fillStyle = color;
|
|
5037
5151
|
if (isThroughTrain) {
|
|
5038
5152
|
drawThroughTrain(ctx, arrivalTimePixel, y);
|
|
5039
5153
|
}
|
|
@@ -5045,19 +5159,19 @@ const drawOccupationZone = (ctx, stcContext, { zone, yOffset, position, isSelect
|
|
|
5045
5159
|
});
|
|
5046
5160
|
}
|
|
5047
5161
|
// Draw dashed lines linking trains tracks occupancy to their paths on the SpaceTimeChart (when relevant):
|
|
5048
|
-
ctx.strokeStyle =
|
|
5049
|
-
ctx.lineWidth =
|
|
5162
|
+
ctx.strokeStyle = color;
|
|
5163
|
+
ctx.lineWidth = size;
|
|
5050
5164
|
ctx.setLineDash([1, 4]);
|
|
5051
|
-
if (zone.
|
|
5165
|
+
if (zone.startDirection) {
|
|
5052
5166
|
ctx.beginPath();
|
|
5053
5167
|
ctx.moveTo(arrivalTimePixel, y);
|
|
5054
|
-
ctx.lineTo(arrivalTimePixel, zone.
|
|
5168
|
+
ctx.lineTo(arrivalTimePixel, zone.startDirection === 'up' ? yStart : yEnd);
|
|
5055
5169
|
ctx.stroke();
|
|
5056
5170
|
}
|
|
5057
|
-
if (zone.
|
|
5171
|
+
if (zone.endDirection) {
|
|
5058
5172
|
ctx.beginPath();
|
|
5059
5173
|
ctx.moveTo(departureTimePixel, y);
|
|
5060
|
-
ctx.lineTo(departureTimePixel, zone.
|
|
5174
|
+
ctx.lineTo(departureTimePixel, zone.endDirection === 'up' ? yStart : yEnd);
|
|
5061
5175
|
ctx.stroke();
|
|
5062
5176
|
}
|
|
5063
5177
|
ctx.setLineDash([]);
|
|
@@ -5075,24 +5189,27 @@ const drawOccupationZone = (ctx, stcContext, { zone, yOffset, position, isSelect
|
|
|
5075
5189
|
|
|
5076
5190
|
const Y_OFFSET_INCREMENT = 4;
|
|
5077
5191
|
const MAX_ZONES = 9;
|
|
5192
|
+
function isOccupancyPickingElement(element) {
|
|
5193
|
+
return element.type === 'occupancyZone';
|
|
5194
|
+
}
|
|
5078
5195
|
const OccupancyZonesLayer = ({ tracks, occupancyZones, position, topPadding, selectedTrainId, }) => {
|
|
5079
5196
|
const instructionsToDraw = useMemo(() => {
|
|
5080
5197
|
const instructions = [];
|
|
5081
5198
|
if (!tracks || !occupancyZones || occupancyZones.length === 0)
|
|
5082
5199
|
return instructions;
|
|
5083
|
-
const sortedOccupancyZones = occupancyZones.sort((a, b) => a.
|
|
5200
|
+
const sortedOccupancyZones = occupancyZones.sort((a, b) => a.startTime - b.startTime);
|
|
5084
5201
|
tracks.forEach((track, index) => {
|
|
5085
5202
|
const trackY = topPadding + CANVAS_PADDING + index * TRACK_HEIGHT_CONTAINER;
|
|
5086
5203
|
const filteredOccupancyZones = sortedOccupancyZones.filter((zone) => zone.trackId === track.id);
|
|
5087
|
-
let
|
|
5088
|
-
let
|
|
5204
|
+
let primaryStartTime = 0;
|
|
5205
|
+
let lastEndTime = 0;
|
|
5089
5206
|
let yPosition = OCCUPANCY_ZONE_Y_START;
|
|
5090
5207
|
let yOffset = Y_OFFSET_INCREMENT;
|
|
5091
5208
|
let zoneCounter = 0;
|
|
5092
5209
|
let zoneIndex = 0;
|
|
5093
5210
|
while (zoneIndex < filteredOccupancyZones.length) {
|
|
5094
5211
|
const zone = filteredOccupancyZones[zoneIndex];
|
|
5095
|
-
const {
|
|
5212
|
+
const { startTime, endTime } = zone;
|
|
5096
5213
|
// * if the zone is not overlapping with any previous one, draw it in the center of the track
|
|
5097
5214
|
// * and reset the primary values
|
|
5098
5215
|
// *
|
|
@@ -5102,11 +5219,11 @@ const OccupancyZonesLayer = ({ tracks, occupancyZones, position, topPadding, sel
|
|
|
5102
5219
|
// * if the zone is overlapping with the previous one and the counter is higher than the max zones
|
|
5103
5220
|
// * draw the remaining trains box
|
|
5104
5221
|
// *
|
|
5105
|
-
if (
|
|
5222
|
+
if (startTime > lastEndTime) {
|
|
5106
5223
|
// reset to initial value if the zone is not overlapping
|
|
5107
5224
|
yPosition = OCCUPANCY_ZONE_Y_START;
|
|
5108
|
-
|
|
5109
|
-
|
|
5225
|
+
primaryStartTime = startTime;
|
|
5226
|
+
lastEndTime = endTime;
|
|
5110
5227
|
yOffset = Y_OFFSET_INCREMENT;
|
|
5111
5228
|
zoneCounter = 1;
|
|
5112
5229
|
instructions.push({
|
|
@@ -5119,7 +5236,7 @@ const OccupancyZonesLayer = ({ tracks, occupancyZones, position, topPadding, sel
|
|
|
5119
5236
|
}
|
|
5120
5237
|
// if so and it's an even index, move it to the bottom, if it's an odd index, move it to the top
|
|
5121
5238
|
else if (zoneCounter < MAX_ZONES) {
|
|
5122
|
-
if (
|
|
5239
|
+
if (startTime >= primaryStartTime) {
|
|
5123
5240
|
if (zoneCounter % 2 === 0) {
|
|
5124
5241
|
yPosition -= yOffset;
|
|
5125
5242
|
}
|
|
@@ -5128,8 +5245,8 @@ const OccupancyZonesLayer = ({ tracks, occupancyZones, position, topPadding, sel
|
|
|
5128
5245
|
}
|
|
5129
5246
|
}
|
|
5130
5247
|
// update the last departure time if the current zone is longer
|
|
5131
|
-
if (
|
|
5132
|
-
|
|
5248
|
+
if (endTime >= lastEndTime)
|
|
5249
|
+
lastEndTime = endTime;
|
|
5133
5250
|
instructions.push({
|
|
5134
5251
|
type: 'occupancyZone',
|
|
5135
5252
|
zone,
|
|
@@ -5142,12 +5259,12 @@ const OccupancyZonesLayer = ({ tracks, occupancyZones, position, topPadding, sel
|
|
|
5142
5259
|
}
|
|
5143
5260
|
// else, if there are too much trains:
|
|
5144
5261
|
else {
|
|
5145
|
-
const nextIndex = filteredOccupancyZones.findIndex((filteredZone, i) => i > zoneIndex && filteredZone.
|
|
5262
|
+
const nextIndex = filteredOccupancyZones.findIndex((filteredZone, i) => i > zoneIndex && filteredZone.startTime >= lastEndTime);
|
|
5146
5263
|
const remainingTrainsNb = nextIndex - zoneIndex;
|
|
5147
5264
|
instructions.push({
|
|
5148
5265
|
type: 'remainingTrains',
|
|
5149
5266
|
amount: remainingTrainsNb,
|
|
5150
|
-
time: (
|
|
5267
|
+
time: (startTime + endTime) / 2,
|
|
5151
5268
|
offsetY: trackY,
|
|
5152
5269
|
});
|
|
5153
5270
|
zoneIndex += remainingTrainsNb;
|
|
@@ -5180,20 +5297,31 @@ const OccupancyZonesLayer = ({ tracks, occupancyZones, position, topPadding, sel
|
|
|
5180
5297
|
}, [position, instructionsToDraw]);
|
|
5181
5298
|
const pickingFunction = useCallback((imageData, { registerPickingElement, getTimePixel, getSpacePixel }, scalingRatio) => {
|
|
5182
5299
|
const flatStepOffsetY = getSpacePixel(position);
|
|
5300
|
+
const flatStepEndY = getSpacePixel(position, true);
|
|
5183
5301
|
instructionsToDraw.forEach((instruction) => {
|
|
5184
5302
|
if (instruction.type === 'occupancyZone') {
|
|
5185
|
-
const x = getTimePixel(instruction.zone.
|
|
5303
|
+
const x = getTimePixel(instruction.zone.startTime);
|
|
5186
5304
|
const y = instruction.offsetY + flatStepOffsetY;
|
|
5187
|
-
const width = getTimePixel(instruction.zone.
|
|
5305
|
+
const width = getTimePixel(instruction.zone.endTime) - x;
|
|
5188
5306
|
const height = OCCUPANCY_ZONE_HEIGHT;
|
|
5189
5307
|
const margin = 6;
|
|
5190
5308
|
const pickingElement = {
|
|
5191
5309
|
type: 'occupancyZone',
|
|
5192
|
-
|
|
5310
|
+
pathId: instruction.zone.trainId,
|
|
5193
5311
|
};
|
|
5194
5312
|
const pickingIndex = registerPickingElement(pickingElement);
|
|
5195
5313
|
const color = hexToRgb(indexToColor(pickingIndex));
|
|
5196
5314
|
drawAliasedRect(imageData, { x: x - margin, y: y - margin }, width + 2 * margin, height + 2 * margin, color, scalingRatio);
|
|
5315
|
+
if (instruction.zone.startDirection) {
|
|
5316
|
+
const yStart = instruction.zone.startDirection === 'up' ? flatStepOffsetY : y;
|
|
5317
|
+
const yStop = instruction.zone.startDirection === 'up' ? y : flatStepEndY;
|
|
5318
|
+
drawAliasedRect(imageData, { x: x - margin, y: yStart - margin }, 2 * margin, yStop - yStart + 2 * margin, color, scalingRatio);
|
|
5319
|
+
}
|
|
5320
|
+
if (instruction.zone.endDirection) {
|
|
5321
|
+
const yStart = instruction.zone.endDirection === 'up' ? flatStepOffsetY : y;
|
|
5322
|
+
const yStop = instruction.zone.endDirection === 'up' ? y : flatStepEndY;
|
|
5323
|
+
drawAliasedRect(imageData, { x: x + width - margin, y: yStart - margin }, 2 * margin, yStop - yStart + 2 * margin, color, scalingRatio);
|
|
5324
|
+
}
|
|
5197
5325
|
}
|
|
5198
5326
|
});
|
|
5199
5327
|
}, [position, instructionsToDraw]);
|
|
@@ -5330,7 +5458,7 @@ const TrackOccupancyStandalone = ({ tracks, occupancyZones, selectedTrainId, onS
|
|
|
5330
5458
|
const manchetteWithSpaceTimeChartRef = useRef(null);
|
|
5331
5459
|
const spaceTimeChartRef = useRef(null);
|
|
5332
5460
|
const defaultTimeOrigin = useMemo(() => {
|
|
5333
|
-
const minTime = Math.min(...(occupancyZones.map((zone) => zone.
|
|
5461
|
+
const minTime = Math.min(...(occupancyZones.map((zone) => zone.startTime) || Date.now()));
|
|
5334
5462
|
// Take first round hour before minTime:
|
|
5335
5463
|
return Math.floor(minTime / HOUR) * HOUR;
|
|
5336
5464
|
}, [occupancyZones]);
|
|
@@ -5379,8 +5507,8 @@ const TrackOccupancyStandalone = ({ tracks, occupancyZones, selectedTrainId, onS
|
|
|
5379
5507
|
React.createElement(SpaceTimeChart, { className: "inset-0 absolute h-full", ...spaceTimeChartProps, onClick: onSelectedTrainIdChange &&
|
|
5380
5508
|
(({ hoveredItem }) => {
|
|
5381
5509
|
if (hoveredItem?.layer === 'overlay' &&
|
|
5382
|
-
hoveredItem.element
|
|
5383
|
-
const newId = hoveredItem.element.
|
|
5510
|
+
isOccupancyPickingElement(hoveredItem.element)) {
|
|
5511
|
+
const newId = hoveredItem.element.pathId;
|
|
5384
5512
|
onSelectedTrainIdChange(newId === selectedTrainId ? undefined : newId);
|
|
5385
5513
|
}
|
|
5386
5514
|
else {
|
|
@@ -5389,5 +5517,5 @@ const TrackOccupancyStandalone = ({ tracks, occupancyZones, selectedTrainId, onS
|
|
|
5389
5517
|
}) }))))));
|
|
5390
5518
|
};
|
|
5391
5519
|
|
|
5392
|
-
export { CANVAS_PADDING, COLORS, CanvasContext, ConflictLayer, ConflictTooltip, DEFAULT_LEVEL, DEFAULT_THEME, DEFAULT_ZOOM_MS_PER_PX, FONTS, MINUTES_TEXT_OFFSET, Manchette, ManchetteWithSpaceTimeChart, MouseContext, OCCUPANCY_ZONE_HEIGHT, OCCUPANCY_ZONE_Y_START, OccupancyBlockLayer, PathLayer, PatternRect, Quadrilateral, STATION_TEXT_OFFSET, SpaceTimeChart, SpaceTimeChartContext, SpeedSpaceChart, TICKS_PATTERN, TICKS_PRIORITIES, TRACK_HEIGHT_CONTAINER, TimeCaptions, Tooltip$1 as Tooltip, TrackOccupancyCanvas, TrackOccupancyManchette, TrackOccupancyStandalone, Waypoint as WaypointComponent, WorkScheduleLayer, ZoomRect, getCrispLineCoordinate, getSpaceAtTime, isConflictPickingElement, isInteractiveWaypoint, isPathOnScreen, isPointPickingElement, isSegmentPickingElement, positionKmToMm, positionMmToKm, timeScaleToZoomValue, useDraw, useManchetteWithSpaceTimeChart, usePaths, usePicking };
|
|
5520
|
+
export { BASE_WAYPOINT_HEIGHT, CANVAS_PADDING, COLORS, CanvasContext, ConflictLayer, ConflictTooltip, DEFAULT_LEVEL, DEFAULT_THEME, DEFAULT_ZOOM_MS_PER_PX, FONTS, MINUTES_TEXT_OFFSET, Manchette, ManchetteWithSpaceTimeChart, MouseContext, OCCUPANCY_ZONE_HEIGHT, OCCUPANCY_ZONE_Y_START, OccupancyBlockLayer, PathLayer, PatternRect, Quadrilateral, STATION_TEXT_OFFSET, SpaceTimeChart, SpaceTimeChartContext, SpeedSpaceChart, TICKS_PATTERN, TICKS_PRIORITIES, TRACK_HEIGHT_CONTAINER, TimeCaptions, Tooltip$1 as Tooltip, TrackOccupancyCanvas, TrackOccupancyManchette, TrackOccupancyStandalone, Waypoint as WaypointComponent, WorkScheduleLayer, ZoomRect, computeRectZoomOffsets, getCrispLineCoordinate, getSpaceAtTime, isConflictPickingElement, isInteractiveWaypoint, isOccupancyPickingElement, isPathOnScreen, isPointPickingElement, isSegmentPickingElement, positionKmToMm, positionMmToKm, timeScaleToZoomValue, useDraw, useManchetteWithSpaceTimeChart, usePaths, usePicking };
|
|
5393
5521
|
//# sourceMappingURL=index.esm.js.map
|