@osrd-project/ui-charts 0.0.74 → 0.0.76
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/dist/index.esm.js +584 -381
- package/dist/index.esm.js.map +1 -1
- package/dist/manchette/components/Manchette.d.ts +4 -3
- package/dist/manchette/components/Waypoint.d.ts +2 -2
- package/dist/manchette/hooks/useManchetteWithSpaceTimeChart.d.ts +11 -1
- package/dist/manchette/index.d.ts +3 -2
- package/dist/manchette/types.d.ts +0 -5
- package/dist/manchette/utils/helpers.d.ts +1 -5
- package/dist/manchette/utils/index.d.ts +3 -2
- package/dist/spaceTimeChart/lib/types.d.ts +4 -6
- package/dist/spaceTimeChart/utils/scales.d.ts +5 -0
- package/dist/theme.css +1678 -2653
- package/dist/theme.css.map +1 -1
- package/dist/trackOccupancyDiagram/components/TrackOccupancyCanvas.d.ts +10 -2
- package/dist/trackOccupancyDiagram/components/TrackOccupancyManchette.d.ts +5 -3
- package/dist/trackOccupancyDiagram/components/TrackOccupancyStandalone.d.ts +10 -0
- package/dist/trackOccupancyDiagram/components/consts.d.ts +3 -1
- package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawOccupancyZones.d.ts +13 -14
- package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawOccupancyZonesTexts.d.ts +2 -2
- package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawTracks.d.ts +7 -15
- package/dist/trackOccupancyDiagram/components/layers/OccupancyZonesLayer.d.ts +7 -9
- package/dist/trackOccupancyDiagram/components/layers/TracksLayer.d.ts +6 -3
- package/dist/trackOccupancyDiagram/components/types.d.ts +8 -17
- package/dist/trackOccupancyDiagram/index.d.ts +3 -0
- package/package.json +8 -8
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React, { useState, useEffect, createContext, useContext, useRef, useCallback, useMemo,
|
|
1
|
+
import React, { useState, useEffect, createContext, useContext, useRef, useCallback, useMemo, Fragment } from 'react';
|
|
2
2
|
import cx from 'classnames';
|
|
3
|
-
import { clamp as clamp$1, isEqual, inRange, last, sortBy, sum } from 'lodash';
|
|
3
|
+
import { clamp as clamp$1, isEqual, inRange, last, flatten, sortBy, sum } from 'lodash';
|
|
4
4
|
import chroma from 'chroma-js';
|
|
5
5
|
import { ZoomOut, ZoomIn, Iterations, Plus, Dash, KebabHorizontal, X } from '@osrd-project/ui-icons';
|
|
6
6
|
import { Checkbox } from '@osrd-project/ui-core';
|
|
@@ -82,7 +82,7 @@ undefined);
|
|
|
82
82
|
|
|
83
83
|
const DEFAULT_PATH_END = 'stop';
|
|
84
84
|
// CANVAS SPECIFIC TYPES:
|
|
85
|
-
const PICKING_LAYERS = ['paths'];
|
|
85
|
+
const PICKING_LAYERS = ['paths', 'overlay'];
|
|
86
86
|
const LAYERS = ['background', 'graduations', 'paths', 'overlay', 'captions'];
|
|
87
87
|
|
|
88
88
|
/**
|
|
@@ -467,7 +467,7 @@ function useCanvas$1(dom, inputStcContext, position) {
|
|
|
467
467
|
return;
|
|
468
468
|
const ctx = contextsRef.current[`${PICKING}-${layer}`];
|
|
469
469
|
const set = pickingFunctions.current[layer];
|
|
470
|
-
if (ctx) {
|
|
470
|
+
if (ctx && ctx.canvas.width && ctx.canvas.height) {
|
|
471
471
|
const { width, height } = sizeRef.current;
|
|
472
472
|
ctx.clearRect(0, 0, width, height);
|
|
473
473
|
const imageData = ctx.getImageData(0, 0, ctx.canvas.width, ctx.canvas.height);
|
|
@@ -711,10 +711,12 @@ function getSpacePixels(getSpacePixel, position) {
|
|
|
711
711
|
}
|
|
712
712
|
|
|
713
713
|
const SpaceGraduations = () => {
|
|
714
|
-
const drawingFunction = useCallback((ctx, { timePixelOffset, getSpacePixel, operationalPoints, swapAxis, width, height, theme: { spaceGraduationsStyles }, }) => {
|
|
714
|
+
const drawingFunction = useCallback((ctx, { timePixelOffset, getSpacePixel, operationalPoints, flatSteps, swapAxis, width, height, theme: { spaceGraduationsStyles }, }) => {
|
|
715
715
|
const axisSize = !swapAxis ? width : height;
|
|
716
716
|
// Draw operational point lines:
|
|
717
717
|
operationalPoints.forEach((point) => {
|
|
718
|
+
if (flatSteps.has(point.position))
|
|
719
|
+
return;
|
|
718
720
|
const styles = spaceGraduationsStyles[point.importanceLevel || 0];
|
|
719
721
|
if (!styles)
|
|
720
722
|
return;
|
|
@@ -922,7 +924,9 @@ const RANGES_FORMATER = [
|
|
|
922
924
|
HOURS_FORMATTER,
|
|
923
925
|
];
|
|
924
926
|
const TimeCaptions = () => {
|
|
925
|
-
const drawingFunction = useCallback((ctx, { timeScale, timeOrigin, timePixelOffset, getTimePixel, swapAxis, width, height, theme: { background, breakpoints, timeRanges, timeCaptionsPriorities, timeCaptionsStyles, timeGraduationsStyles, dateCaptionsStyle, }, captionSize, hideDates, showTicks, }) => {
|
|
927
|
+
const drawingFunction = useCallback((ctx, { timeScale, timeOrigin, timePixelOffset, getTimePixel, swapAxis, width, height, theme: { background, breakpoints, timeRanges, timeCaptionsPriorities, timeCaptionsStyles, timeGraduationsStyles, dateCaptionsStyle, }, captionSize, hideTimeCaptions, hideDates, showTicks, }) => {
|
|
928
|
+
if (hideTimeCaptions)
|
|
929
|
+
return;
|
|
926
930
|
const timeAxisSize = !swapAxis ? width : height;
|
|
927
931
|
const spaceAxisSize = (!swapAxis ? height : width) - captionSize;
|
|
928
932
|
// Add some margin, so that captions of times right outside the stage are still visible:
|
|
@@ -1350,6 +1354,20 @@ function spaceScalesToBinaryTree(spaceOrigin, spaceScales, skipSiblingReferences
|
|
|
1350
1354
|
}
|
|
1351
1355
|
return buildTree(normalizedScales);
|
|
1352
1356
|
}
|
|
1357
|
+
/**
|
|
1358
|
+
* This function takes a sequence of SpaceScales, identifies the flat steps (i.e. the scales that do
|
|
1359
|
+
* not increase the position), and returns them in a set.
|
|
1360
|
+
*/
|
|
1361
|
+
function getFlatSteps(spaceScales) {
|
|
1362
|
+
const flatSteps = [];
|
|
1363
|
+
for (let i = 1; i < spaceScales.length; i++) {
|
|
1364
|
+
const { to: previous } = spaceScales[i - 1];
|
|
1365
|
+
const { to: current } = spaceScales[i];
|
|
1366
|
+
if (previous === current)
|
|
1367
|
+
flatSteps.push(current);
|
|
1368
|
+
}
|
|
1369
|
+
return new Set(flatSteps);
|
|
1370
|
+
}
|
|
1353
1371
|
/**
|
|
1354
1372
|
* This function takes a NormalizedScaleTree and a position, and returns the leaf node from the
|
|
1355
1373
|
* tree that contains that position.
|
|
@@ -1407,7 +1425,12 @@ function getPixelToTime(timeOrigin, pixelOffset, timeScale) {
|
|
|
1407
1425
|
}
|
|
1408
1426
|
function getSpaceToPixel(pixelOffset, binaryTree) {
|
|
1409
1427
|
return (position, fromEnd) => {
|
|
1410
|
-
const { from, pixelFrom, coefficient } = getNormalizedScaleAtPosition(position, binaryTree, fromEnd);
|
|
1428
|
+
const { from, pixelFrom, pixelTo, coefficient } = getNormalizedScaleAtPosition(position, binaryTree, fromEnd);
|
|
1429
|
+
// Rare case where coefficient is 0:
|
|
1430
|
+
// (occurs when there is just a flat step, for instance)
|
|
1431
|
+
if (coefficient === 0)
|
|
1432
|
+
return pixelOffset + (fromEnd ? pixelTo : pixelFrom);
|
|
1433
|
+
// Normal case: We simply interpolate
|
|
1411
1434
|
return pixelOffset + pixelFrom + (position - from) / coefficient;
|
|
1412
1435
|
};
|
|
1413
1436
|
}
|
|
@@ -1511,20 +1534,27 @@ const DEFAULT_LEVEL = 2;
|
|
|
1511
1534
|
*/
|
|
1512
1535
|
const PathLayer = ({ path, color, level = DEFAULT_LEVEL, pickingTolerance = DEFAULT_PICKING_TOLERANCE, border, }) => {
|
|
1513
1536
|
/**
|
|
1514
|
-
* This function returns the list of points to join to draw the path.
|
|
1515
|
-
*
|
|
1537
|
+
* This function returns the list of points to join to draw the path. As it can be discontinuous,
|
|
1538
|
+
* 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 in the flat
|
|
1540
|
+
* step layer).
|
|
1541
|
+
*
|
|
1542
|
+
* It will be both used to render the visible path, and the segments on the picking layer.
|
|
1516
1543
|
*/
|
|
1517
|
-
const
|
|
1518
|
-
const
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1544
|
+
const getPathLines = useCallback(({ getTimePixel, getSpacePixel, spaceScaleTree, flatSteps, timeAxis, spaceAxis, width, height, }) => {
|
|
1545
|
+
const lines = [];
|
|
1546
|
+
let currentLine = [];
|
|
1547
|
+
const { points } = path;
|
|
1548
|
+
for (let i = 0; i < points.length; i++) {
|
|
1549
|
+
const { position, time } = points[i];
|
|
1550
|
+
if (i === 0) {
|
|
1551
|
+
currentLine.push({
|
|
1522
1552
|
[timeAxis]: getTimePixel(time),
|
|
1523
1553
|
[spaceAxis]: getSpacePixel(position),
|
|
1524
1554
|
});
|
|
1525
1555
|
}
|
|
1526
1556
|
else {
|
|
1527
|
-
const { position: prevPosition, time: prevTime } =
|
|
1557
|
+
const { position: prevPosition, time: prevTime } = points[i - 1];
|
|
1528
1558
|
const spaceBreakPoints = getSpaceBreakpoints(prevPosition, position, spaceScaleTree);
|
|
1529
1559
|
let previousBreakPosition = -Infinity;
|
|
1530
1560
|
spaceBreakPoints.forEach((breakPosition, index) => {
|
|
@@ -1538,24 +1568,47 @@ const PathLayer = ({ path, color, level = DEFAULT_LEVEL, pickingTolerance = DEFA
|
|
|
1538
1568
|
: false;
|
|
1539
1569
|
const breakTime = prevTime +
|
|
1540
1570
|
((breakPosition - prevPosition) / (position - prevPosition)) * (time - prevTime);
|
|
1541
|
-
|
|
1571
|
+
currentLine.push({
|
|
1542
1572
|
[timeAxis]: getTimePixel(breakTime),
|
|
1543
1573
|
[spaceAxis]: getSpacePixel(breakPosition, readSpacePixelFromEnd),
|
|
1544
1574
|
});
|
|
1545
1575
|
previousBreakPosition = breakPosition;
|
|
1546
1576
|
});
|
|
1547
|
-
|
|
1577
|
+
const newPoint = {
|
|
1548
1578
|
[timeAxis]: getTimePixel(time),
|
|
1549
1579
|
[spaceAxis]: getSpacePixel(position),
|
|
1550
|
-
}
|
|
1580
|
+
};
|
|
1581
|
+
if (position === prevPosition && flatSteps.has(position)) {
|
|
1582
|
+
lines.push(currentLine);
|
|
1583
|
+
currentLine = [newPoint];
|
|
1584
|
+
}
|
|
1585
|
+
else if (time === prevTime) {
|
|
1586
|
+
lines.push(currentLine);
|
|
1587
|
+
currentLine = [newPoint];
|
|
1588
|
+
}
|
|
1589
|
+
else {
|
|
1590
|
+
currentLine.push(newPoint);
|
|
1591
|
+
}
|
|
1551
1592
|
}
|
|
1593
|
+
}
|
|
1594
|
+
lines.push(currentLine);
|
|
1595
|
+
// Only keep segments that intersect with the current visible time frame:
|
|
1596
|
+
const visibleLines = [];
|
|
1597
|
+
const minPixel = 0;
|
|
1598
|
+
const maxPixel = timeAxis === 'x' ? width : height;
|
|
1599
|
+
lines.forEach((line) => {
|
|
1600
|
+
const lastPointBeforeMinIndex = line.findLastIndex((p) => p[timeAxis] < minPixel);
|
|
1601
|
+
const firstPointAfterMaxIndex = line.findIndex((p) => p[timeAxis] > maxPixel);
|
|
1602
|
+
const visibleLine = line.slice(lastPointBeforeMinIndex === -1 ? 0 : lastPointBeforeMinIndex, (firstPointAfterMaxIndex === -1 ? line.length : firstPointAfterMaxIndex) + 1);
|
|
1603
|
+
if (visibleLine.length)
|
|
1604
|
+
visibleLines.push(visibleLine);
|
|
1552
1605
|
});
|
|
1553
|
-
return
|
|
1606
|
+
return visibleLines;
|
|
1554
1607
|
}, [path]);
|
|
1555
1608
|
/**
|
|
1556
1609
|
* This function returns the list of important points, where the mouse can snap.
|
|
1557
1610
|
*/
|
|
1558
|
-
const getSnapPoints = useCallback(({ getTimePixel, getSpacePixel, timeAxis, spaceAxis, operationalPoints, }) => {
|
|
1611
|
+
const getSnapPoints = useCallback(({ getTimePixel, getSpacePixel, timeAxis, spaceAxis, operationalPoints, width, height, }) => {
|
|
1559
1612
|
const res = [];
|
|
1560
1613
|
const stopPositions = new Set(operationalPoints.map((p) => p.position));
|
|
1561
1614
|
path.points.forEach(({ position, time }) => {
|
|
@@ -1565,8 +1618,10 @@ const PathLayer = ({ path, color, level = DEFAULT_LEVEL, pickingTolerance = DEFA
|
|
|
1565
1618
|
[spaceAxis]: getSpacePixel(position),
|
|
1566
1619
|
});
|
|
1567
1620
|
});
|
|
1568
|
-
|
|
1569
|
-
|
|
1621
|
+
// Only keep visible points:
|
|
1622
|
+
const radius = STYLES[level].width + pickingTolerance;
|
|
1623
|
+
return res.filter((p) => inRange(p.x, -radius, width + radius) && inRange(p.y, -radius, height + radius));
|
|
1624
|
+
}, [level, path.points, pickingTolerance]);
|
|
1570
1625
|
/**
|
|
1571
1626
|
* This function draws the stops of the path on the operational points.
|
|
1572
1627
|
*/
|
|
@@ -1576,9 +1631,11 @@ const PathLayer = ({ path, color, level = DEFAULT_LEVEL, pickingTolerance = DEFA
|
|
|
1576
1631
|
if (i) {
|
|
1577
1632
|
const { position: prevPosition, time: prevTime } = a[i - 1];
|
|
1578
1633
|
if (prevPosition === position && stopPositions.has(position)) {
|
|
1579
|
-
//
|
|
1580
|
-
|
|
1581
|
-
|
|
1634
|
+
// Only draw the stop when there is no flat step
|
|
1635
|
+
// (i.e. when there's only one space pixel):
|
|
1636
|
+
const rawPixels = getSpacePixels(getSpacePixel, position);
|
|
1637
|
+
if (rawPixels.length === 1) {
|
|
1638
|
+
const spacePixel = getCrispLineCoordinate(rawPixels[0], ctx.lineWidth);
|
|
1582
1639
|
ctx.beginPath();
|
|
1583
1640
|
if (!swapAxis) {
|
|
1584
1641
|
ctx.moveTo(getTimePixel(prevTime), spacePixel);
|
|
@@ -1589,7 +1646,7 @@ const PathLayer = ({ path, color, level = DEFAULT_LEVEL, pickingTolerance = DEFA
|
|
|
1589
1646
|
ctx.lineTo(spacePixel, getTimePixel(time));
|
|
1590
1647
|
}
|
|
1591
1648
|
ctx.stroke();
|
|
1592
|
-
}
|
|
1649
|
+
}
|
|
1593
1650
|
}
|
|
1594
1651
|
}
|
|
1595
1652
|
});
|
|
@@ -1667,7 +1724,7 @@ const PathLayer = ({ path, color, level = DEFAULT_LEVEL, pickingTolerance = DEFA
|
|
|
1667
1724
|
drawPathExtremity(ctx, getTimePixel(from.time), getSpacePixel(from.position), swapAxis, 'from', getPathDirection(path, 0), fromEnd);
|
|
1668
1725
|
drawPathExtremity(ctx, getTimePixel(to.time), getSpacePixel(to.position), swapAxis, 'to', getPathDirection(path, path.points.length - 1, true), toEnd);
|
|
1669
1726
|
}, [path]);
|
|
1670
|
-
const computePathLength = useCallback((operationalPoints,
|
|
1727
|
+
const computePathLength = useCallback((operationalPoints, lines) => {
|
|
1671
1728
|
let totalLength = 0;
|
|
1672
1729
|
// Compute length of pauses
|
|
1673
1730
|
const stopPositions = new Set(operationalPoints.map((p) => p.position));
|
|
@@ -1680,11 +1737,13 @@ const PathLayer = ({ path, color, level = DEFAULT_LEVEL, pickingTolerance = DEFA
|
|
|
1680
1737
|
}
|
|
1681
1738
|
});
|
|
1682
1739
|
// Compute length of pathSegments
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1740
|
+
lines.forEach((line) => {
|
|
1741
|
+
line.forEach(({ x, y }, i, a) => {
|
|
1742
|
+
if (i > 0) {
|
|
1743
|
+
const { x: prevX, y: prevY } = a[i - 1];
|
|
1744
|
+
totalLength += Math.sqrt(Math.pow(prevX - x, 2) + Math.pow(prevY - y, 2));
|
|
1745
|
+
}
|
|
1746
|
+
});
|
|
1688
1747
|
});
|
|
1689
1748
|
return totalLength;
|
|
1690
1749
|
}, [path]);
|
|
@@ -1695,29 +1754,31 @@ const PathLayer = ({ path, color, level = DEFAULT_LEVEL, pickingTolerance = DEFA
|
|
|
1695
1754
|
const mainPathStyle = STYLES[level];
|
|
1696
1755
|
const totalPathWidth = border.offset * 2 + mainPathStyle.width;
|
|
1697
1756
|
const backgroundColor = border.backgroundColor || '#fff';
|
|
1698
|
-
const
|
|
1757
|
+
const lines = getPathLines(stcContext);
|
|
1699
1758
|
ctx.save();
|
|
1700
|
-
|
|
1701
|
-
const drawSegments = (lineWidth, borderColor = border.color) => {
|
|
1759
|
+
const drawLines = (lineWidth, borderColor = border.color) => {
|
|
1702
1760
|
ctx.strokeStyle = borderColor;
|
|
1703
1761
|
ctx.lineWidth = lineWidth;
|
|
1704
1762
|
ctx.lineCap = 'round';
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1763
|
+
lines.forEach((segments) => {
|
|
1764
|
+
ctx.beginPath();
|
|
1765
|
+
segments.forEach(({ x, y }, i) => {
|
|
1766
|
+
if (x === segments[i - 1]?.x && y === segments[i - 1]?.y)
|
|
1767
|
+
return;
|
|
1768
|
+
if (i === 0) {
|
|
1769
|
+
ctx.moveTo(x, y);
|
|
1770
|
+
}
|
|
1771
|
+
else {
|
|
1772
|
+
ctx.lineTo(x, y);
|
|
1773
|
+
}
|
|
1774
|
+
});
|
|
1775
|
+
ctx.stroke();
|
|
1714
1776
|
});
|
|
1715
|
-
ctx.stroke();
|
|
1716
1777
|
};
|
|
1717
|
-
|
|
1718
|
-
|
|
1778
|
+
drawLines(totalPathWidth + borderWidth * 2);
|
|
1779
|
+
drawLines(totalPathWidth, backgroundColor);
|
|
1719
1780
|
ctx.restore();
|
|
1720
|
-
}, [border,
|
|
1781
|
+
}, [border, getPathLines, level]);
|
|
1721
1782
|
const drawAll = useCallback((ctx, stcContext) => {
|
|
1722
1783
|
drawBorder(ctx, stcContext);
|
|
1723
1784
|
// Draw stops:
|
|
@@ -1733,31 +1794,36 @@ const PathLayer = ({ path, color, level = DEFAULT_LEVEL, pickingTolerance = DEFA
|
|
|
1733
1794
|
ctx.setLineDash(style.dashArray || []);
|
|
1734
1795
|
ctx.globalAlpha = style.opacity || 1;
|
|
1735
1796
|
ctx.lineCap = style.lineCap || 'square';
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1797
|
+
const lines = getPathLines(stcContext);
|
|
1798
|
+
lines.forEach((points) => {
|
|
1799
|
+
ctx.beginPath();
|
|
1800
|
+
points.forEach(({ x, y }, i) => {
|
|
1801
|
+
if (i === 0) {
|
|
1802
|
+
ctx.moveTo(x, y);
|
|
1803
|
+
}
|
|
1804
|
+
else {
|
|
1805
|
+
ctx.lineTo(x, y);
|
|
1806
|
+
}
|
|
1807
|
+
});
|
|
1808
|
+
ctx.stroke();
|
|
1745
1809
|
});
|
|
1746
|
-
ctx.stroke();
|
|
1747
1810
|
// Draw extremities:
|
|
1748
1811
|
ctx.setLineDash([]);
|
|
1749
1812
|
ctx.lineWidth = style.endWidth;
|
|
1750
1813
|
drawExtremities(ctx, stcContext);
|
|
1751
1814
|
// Draw label:
|
|
1752
1815
|
if (!stcContext.hidePathsLabels) {
|
|
1753
|
-
const pathLength = computePathLength(stcContext.operationalPoints,
|
|
1754
|
-
|
|
1816
|
+
const pathLength = computePathLength(stcContext.operationalPoints, lines);
|
|
1817
|
+
// TODO:
|
|
1818
|
+
// We should improve how the labels are drawn, and handle discontinuous lines (instead of
|
|
1819
|
+
// flattening the points)
|
|
1820
|
+
drawLabel(ctx, stcContext, path.label, color, flatten(lines), pathLength);
|
|
1755
1821
|
}
|
|
1756
1822
|
}, [
|
|
1757
1823
|
color,
|
|
1758
1824
|
drawPauses,
|
|
1759
1825
|
level,
|
|
1760
|
-
|
|
1826
|
+
getPathLines,
|
|
1761
1827
|
drawExtremities,
|
|
1762
1828
|
computePathLength,
|
|
1763
1829
|
drawLabel,
|
|
@@ -1768,7 +1834,7 @@ const PathLayer = ({ path, color, level = DEFAULT_LEVEL, pickingTolerance = DEFA
|
|
|
1768
1834
|
const drawPicking = useCallback((imageData, stcContext, scalingRatio) => {
|
|
1769
1835
|
const { registerPickingElement } = stcContext;
|
|
1770
1836
|
// Draw segments:
|
|
1771
|
-
|
|
1837
|
+
getPathLines(stcContext).forEach((line) => line.forEach((point, i, a) => {
|
|
1772
1838
|
if (i) {
|
|
1773
1839
|
const previousPoint = a[i - 1];
|
|
1774
1840
|
const pickingElement = {
|
|
@@ -1781,7 +1847,7 @@ const PathLayer = ({ path, color, level = DEFAULT_LEVEL, pickingTolerance = DEFA
|
|
|
1781
1847
|
const lineColor = hexToRgb(indexToColor(index));
|
|
1782
1848
|
drawAliasedLine(imageData, previousPoint, point, lineColor, STYLES[level].width + pickingTolerance, true, scalingRatio);
|
|
1783
1849
|
}
|
|
1784
|
-
});
|
|
1850
|
+
}));
|
|
1785
1851
|
// Draw snap points:
|
|
1786
1852
|
getSnapPoints(stcContext).forEach((point) => {
|
|
1787
1853
|
const pickingElement = {
|
|
@@ -1793,7 +1859,7 @@ const PathLayer = ({ path, color, level = DEFAULT_LEVEL, pickingTolerance = DEFA
|
|
|
1793
1859
|
const lineColor = hexToRgb(indexToColor(index));
|
|
1794
1860
|
drawAliasedDisc(imageData, point, (STYLES[level].width + pickingTolerance) * 2, lineColor, false, scalingRatio);
|
|
1795
1861
|
});
|
|
1796
|
-
}, [
|
|
1862
|
+
}, [getPathLines, getSnapPoints, level, path.id, pickingTolerance]);
|
|
1797
1863
|
usePicking('paths', drawPicking);
|
|
1798
1864
|
return null;
|
|
1799
1865
|
};
|
|
@@ -1850,7 +1916,7 @@ function snapPosition(mousePosition, hoveredItem) {
|
|
|
1850
1916
|
}
|
|
1851
1917
|
|
|
1852
1918
|
const SpaceTimeChart = (props) => {
|
|
1853
|
-
const { operationalPoints, spaceOrigin, spaceScales, timeOrigin, timeScale, xOffset = 0, yOffset = 0, swapAxis, onHoveredChildUpdate, children, additionalChildren, enableSnapping, hideGrid, hidePathsLabels, showTicks, hideDates, theme,
|
|
1919
|
+
const { operationalPoints, spaceOrigin, spaceScales, timeOrigin, timeScale, xOffset = 0, yOffset = 0, swapAxis, onHoveredChildUpdate, children, additionalChildren, enableSnapping, hideTimeCaptions, hideGrid, hidePathsLabels, showTicks, hideDates, theme,
|
|
1854
1920
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
1855
1921
|
onPan, onZoom, onClick, onMouseMove,
|
|
1856
1922
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
@@ -1870,6 +1936,7 @@ const SpaceTimeChart = (props) => {
|
|
|
1870
1936
|
xOffset,
|
|
1871
1937
|
yOffset,
|
|
1872
1938
|
swapAxis,
|
|
1939
|
+
hideTimeCaptions,
|
|
1873
1940
|
hideGrid,
|
|
1874
1941
|
hidePathsLabels,
|
|
1875
1942
|
showTicks,
|
|
@@ -1885,6 +1952,7 @@ const SpaceTimeChart = (props) => {
|
|
|
1885
1952
|
xOffset,
|
|
1886
1953
|
yOffset,
|
|
1887
1954
|
swapAxis,
|
|
1955
|
+
hideTimeCaptions,
|
|
1888
1956
|
hideGrid,
|
|
1889
1957
|
hidePathsLabels,
|
|
1890
1958
|
showTicks,
|
|
@@ -1892,6 +1960,7 @@ const SpaceTimeChart = (props) => {
|
|
|
1892
1960
|
]);
|
|
1893
1961
|
const contextState = useMemo(() => {
|
|
1894
1962
|
const spaceScaleTree = spaceScalesToBinaryTree(spaceOrigin, spaceScales);
|
|
1963
|
+
const flatSteps = getFlatSteps(spaceScales);
|
|
1895
1964
|
const timeAxis = !swapAxis ? 'x' : 'y';
|
|
1896
1965
|
const spaceAxis = !swapAxis ? 'y' : 'x';
|
|
1897
1966
|
// Data translation helpers:
|
|
@@ -1935,6 +2004,7 @@ const SpaceTimeChart = (props) => {
|
|
|
1935
2004
|
operationalPoints,
|
|
1936
2005
|
spaceOrigin,
|
|
1937
2006
|
spaceScaleTree,
|
|
2007
|
+
flatSteps,
|
|
1938
2008
|
timeOrigin,
|
|
1939
2009
|
timeScale,
|
|
1940
2010
|
timePixelOffset,
|
|
@@ -1943,6 +2013,7 @@ const SpaceTimeChart = (props) => {
|
|
|
1943
2013
|
spaceAxis,
|
|
1944
2014
|
swapAxis: !!swapAxis,
|
|
1945
2015
|
enableSnapping: !!enableSnapping,
|
|
2016
|
+
hideTimeCaptions: !!hideTimeCaptions,
|
|
1946
2017
|
hideGrid: !!hideGrid,
|
|
1947
2018
|
hidePathsLabels: !!hidePathsLabels,
|
|
1948
2019
|
showTicks: !!showTicks,
|
|
@@ -2270,7 +2341,13 @@ const PATH_COLOR_DEFAULT = '#8A714B';
|
|
|
2270
2341
|
|
|
2271
2342
|
const getHeightWithoutLastWaypoint = (height) => height - FOOTER_HEIGHT - BASE_WAYPOINT_HEIGHT;
|
|
2272
2343
|
const positionMmToKm = (position) => Math.round((position / 1000000) * 10) / 10;
|
|
2273
|
-
const
|
|
2344
|
+
const positionKmToMm = (position) => position * 1000000;
|
|
2345
|
+
const calcTotalDistance = (ops) => {
|
|
2346
|
+
if (ops.length === 0) {
|
|
2347
|
+
return 0;
|
|
2348
|
+
}
|
|
2349
|
+
return ops.at(-1).position - ops.at(0).position;
|
|
2350
|
+
};
|
|
2274
2351
|
function getDistance(a, b) {
|
|
2275
2352
|
return {
|
|
2276
2353
|
x: b.x - a.x,
|
|
@@ -2278,15 +2355,15 @@ function getDistance(a, b) {
|
|
|
2278
2355
|
};
|
|
2279
2356
|
}
|
|
2280
2357
|
|
|
2281
|
-
const Waypoint = ({ waypoint: { name, secondaryCode, id, position, onClick },
|
|
2358
|
+
const Waypoint = ({ waypoint: { name, secondaryCode, id, position, onClick }, waypointRef, isActive, isMenuActive, }) => (React.createElement("div", { className: cx('flex waypoint items-baseline', {
|
|
2282
2359
|
'waypoint-active': isActive,
|
|
2283
2360
|
'menu-active': isMenuActive,
|
|
2284
|
-
}), id: id, onClick: () => {
|
|
2361
|
+
}), id: id, ref: waypointRef, onClick: () => {
|
|
2285
2362
|
if (onClick && !isMenuActive)
|
|
2286
2363
|
onClick(id);
|
|
2287
2364
|
} },
|
|
2288
2365
|
React.createElement("div", { className: "waypoint-position justify-self-start text-end" }, positionMmToKm(position)),
|
|
2289
|
-
React.createElement("div", {
|
|
2366
|
+
React.createElement("div", { className: "waypoint-name mx-2 justify-self-start" }, name),
|
|
2290
2367
|
React.createElement("div", { className: "waypoint-separator" }),
|
|
2291
2368
|
React.createElement("div", { className: "waypoint-ch font-mono justify-self-end" }, secondaryCode),
|
|
2292
2369
|
React.createElement("div", { className: "waypoint-separator" }),
|
|
@@ -2353,9 +2430,19 @@ const selectWaypointsToDisplay = (waypoints, { height, isProportional, yZoom })
|
|
|
2353
2430
|
* km (isProportional): { coefficient: gives a scale in meter/pixel }
|
|
2354
2431
|
* linear: { size: height in pixel } (each point distributed evenly along the height of manchette.)
|
|
2355
2432
|
*/
|
|
2356
|
-
const getScales = (waypoints, { isProportional, yZoom }, minZoomMillimeterPerPx, maxZoomMillimeterPerPx) => {
|
|
2357
|
-
if (waypoints.length
|
|
2433
|
+
const getScales = (waypoints, { isProportional, yZoom, height }, minZoomMillimeterPerPx, maxZoomMillimeterPerPx) => {
|
|
2434
|
+
if (!waypoints.length)
|
|
2358
2435
|
return [];
|
|
2436
|
+
if (waypoints.length === 1) {
|
|
2437
|
+
const waypoint = waypoints[0];
|
|
2438
|
+
return [
|
|
2439
|
+
{
|
|
2440
|
+
from: waypoint.position,
|
|
2441
|
+
to: waypoint.position,
|
|
2442
|
+
size: height || 1,
|
|
2443
|
+
},
|
|
2444
|
+
];
|
|
2445
|
+
}
|
|
2359
2446
|
if (!isProportional) {
|
|
2360
2447
|
return waypoints.slice(0, -1).map((from, index) => {
|
|
2361
2448
|
const to = waypoints[index + 1];
|
|
@@ -2381,52 +2468,43 @@ const getScales = (waypoints, { isProportional, yZoom }, minZoomMillimeterPerPx,
|
|
|
2381
2468
|
};
|
|
2382
2469
|
const isInteractiveWaypoint = (item) => item != null && typeof item === 'object' && 'id' in item && 'position' in item;
|
|
2383
2470
|
|
|
2384
|
-
const Manchette = ({ zoomYIn, zoomYOut, resetZoom, yZoom = 1, contents,
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
contents.map((content, index) => isInteractiveWaypoint(content) ? (React.createElement("div", { key: index, className: "waypoint-wrapper flex justify-start", style: content.styles },
|
|
2403
|
-
React.createElement(Waypoint, { waypoint: content, nameRef: waypointMenuData?.activeWaypointId === content.id
|
|
2404
|
-
? activeWaypointRef
|
|
2405
|
-
: undefined, isActive: waypointMenuData?.activeWaypointId === content.id, isMenuActive: !!waypointMenuData?.activeWaypointId }))) : (React.createElement(Fragment, { key: index }, content))),
|
|
2406
|
-
children)),
|
|
2407
|
-
React.createElement("div", { className: "manchette-actions" },
|
|
2408
|
-
React.createElement("div", { className: "zoom-buttons" },
|
|
2409
|
-
React.createElement("button", { className: "zoom-out", onClick: zoomYOut, disabled: yZoom <= MIN_ZOOM_Y || !!waypointMenuData?.activeWaypointId },
|
|
2410
|
-
React.createElement(ZoomOut, null)),
|
|
2411
|
-
React.createElement("button", { className: "zoom-in", onClick: zoomYIn, disabled: yZoom >= MAX_ZOOM_Y || !!waypointMenuData?.activeWaypointId },
|
|
2412
|
-
React.createElement(ZoomIn, null)),
|
|
2413
|
-
React.createElement("button", { disabled: !!waypointMenuData?.activeWaypointId, className: "zoom-reset", onClick: resetZoom }, "Fit")),
|
|
2414
|
-
React.createElement("div", { className: "flex items-center ml-auto text-sans font-semibold" },
|
|
2415
|
-
React.createElement("button", { disabled: !!waypointMenuData?.activeWaypointId, className: "toggle-mode", onClick: toggleMode },
|
|
2416
|
-
React.createElement("div", { className: "flex flex-col items-end pr-2" },
|
|
2417
|
-
React.createElement("span", { className: cx({ 'text-grey-30': !isProportional }) }, "Km"),
|
|
2418
|
-
React.createElement("span", { className: cx({ 'text-grey-30': isProportional }) }, "Lin\u00E9aire")))))));
|
|
2419
|
-
};
|
|
2471
|
+
const Manchette = ({ zoomYIn, zoomYOut, resetZoom, yZoom = 1, contents, activeWaypointId, activeWaypointRef, isProportional = true, toggleMode, children, height = INITIAL_OP_LIST_HEIGHT, }) => (React.createElement("div", { className: "manchette-container" },
|
|
2472
|
+
React.createElement("div", { className: "bg-white-100 border-r border-grey-30 relative", style: { minHeight: `${height}px` } },
|
|
2473
|
+
React.createElement("div", { className: "waypoints-list" },
|
|
2474
|
+
contents.map((content, index) => isInteractiveWaypoint(content) ? (React.createElement("div", { key: index, className: "waypoint-wrapper flex justify-start", style: content.styles },
|
|
2475
|
+
React.createElement(Waypoint, { waypoint: content, waypointRef: activeWaypointId === content.id ? activeWaypointRef : undefined, isActive: activeWaypointId === content.id, isMenuActive: !!activeWaypointId }))) : (React.createElement(Fragment, { key: index }, content))),
|
|
2476
|
+
children)),
|
|
2477
|
+
React.createElement("div", { className: "manchette-actions" },
|
|
2478
|
+
React.createElement("div", { className: "zoom-buttons" },
|
|
2479
|
+
React.createElement("button", { className: "zoom-out", onClick: zoomYOut, disabled: yZoom <= MIN_ZOOM_Y || !!activeWaypointId },
|
|
2480
|
+
React.createElement(ZoomOut, null)),
|
|
2481
|
+
React.createElement("button", { className: "zoom-in", onClick: zoomYIn, disabled: yZoom >= MAX_ZOOM_Y || !!activeWaypointId },
|
|
2482
|
+
React.createElement(ZoomIn, null)),
|
|
2483
|
+
React.createElement("button", { disabled: !!activeWaypointId, className: "zoom-reset", onClick: resetZoom }, "Fit")),
|
|
2484
|
+
React.createElement("div", { className: "flex items-center ml-auto text-sans font-semibold" },
|
|
2485
|
+
React.createElement("button", { disabled: !!activeWaypointId, className: "toggle-mode", onClick: toggleMode },
|
|
2486
|
+
React.createElement("div", { className: "flex flex-col items-end pr-2" },
|
|
2487
|
+
React.createElement("span", { className: cx({ 'text-grey-30': !isProportional }) }, "Km"),
|
|
2488
|
+
React.createElement("span", { className: cx({ 'text-grey-30': isProportional }) }, "Lin\u00E9aire")))))));
|
|
2420
2489
|
|
|
2421
|
-
const
|
|
2422
|
-
|
|
2490
|
+
const DEFAULT_MANCHETTE_WITH_SPACE_TIME_CHART_OPTIONS = {
|
|
2491
|
+
displayTimeCaptions: true,
|
|
2492
|
+
enableTimePan: true,
|
|
2493
|
+
enableSpacePan: true,
|
|
2494
|
+
enableTimeZoom: true,
|
|
2495
|
+
};
|
|
2496
|
+
const useManchetteWithSpaceTimeChart = ({ waypoints, manchetteWithSpaceTimeChartRef, height = 561, spaceTimeChartRef, defaultTimeOrigin = 0, defaultSpaceOrigin = 0, defaultXOffset = 0, verticalPadding = BASE_WAYPOINT_HEIGHT / 2, splitPoints = [], options = {}, }) => {
|
|
2497
|
+
const { displayTimeCaptions, enableTimePan, enableSpacePan, enableTimeZoom } = useMemo(() => ({
|
|
2498
|
+
...DEFAULT_MANCHETTE_WITH_SPACE_TIME_CHART_OPTIONS,
|
|
2499
|
+
...options,
|
|
2500
|
+
}), [options]);
|
|
2423
2501
|
const [isShiftPressed, setIsShiftPressed] = useState(false);
|
|
2424
2502
|
const [state, setState] = useState({
|
|
2425
2503
|
xZoom: timeScaleToZoomValue(DEFAULT_ZOOM_MS_PER_PX),
|
|
2426
2504
|
yZoom: 1,
|
|
2427
2505
|
timeOrigin: defaultTimeOrigin,
|
|
2428
2506
|
spaceOrigin: defaultSpaceOrigin,
|
|
2429
|
-
xOffset:
|
|
2507
|
+
xOffset: defaultXOffset,
|
|
2430
2508
|
yOffset: 0,
|
|
2431
2509
|
scrollTo: null,
|
|
2432
2510
|
panning: null,
|
|
@@ -2442,7 +2520,7 @@ const useManchetteWithSpaceTimeChart = ({ waypoints, manchetteWithSpaceTimeChart
|
|
|
2442
2520
|
const setTimeOrigin = useCallback((newTimeOrigin) => {
|
|
2443
2521
|
setState((prev) => ({ ...prev, timeOrigin: newTimeOrigin }));
|
|
2444
2522
|
}, []);
|
|
2445
|
-
const canvasDrawingHeight = height - FOOTER_HEIGHT; // 521
|
|
2523
|
+
const canvasDrawingHeight = Math.max(1 + BASE_WAYPOINT_HEIGHT, height - FOOTER_HEIGHT); // 521
|
|
2446
2524
|
const drawingHeightWithoutTopPadding = canvasDrawingHeight - BASE_WAYPOINT_HEIGHT / 2; // 505
|
|
2447
2525
|
const drawingHeightWithoutBothPadding = canvasDrawingHeight - BASE_WAYPOINT_HEIGHT; // 489
|
|
2448
2526
|
const totalDistance = calcTotalDistance(waypoints);
|
|
@@ -2608,37 +2686,47 @@ const useManchetteWithSpaceTimeChart = ({ waypoints, manchetteWithSpaceTimeChart
|
|
|
2608
2686
|
setState((prev) => ({ ...prev, zoomMode: !prev.zoomMode }));
|
|
2609
2687
|
}, []);
|
|
2610
2688
|
const handleXZoom = useCallback((newXZoom, xPosition = (spaceTimeChartRef?.current?.offsetWidth || 0) / 2) => {
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2689
|
+
if (enableTimeZoom)
|
|
2690
|
+
setState((prev) => ({
|
|
2691
|
+
...prev,
|
|
2692
|
+
...zoomX(prev.xZoom, prev.xOffset, newXZoom, xPosition),
|
|
2693
|
+
}));
|
|
2694
|
+
}, [enableTimeZoom, spaceTimeChartRef]);
|
|
2616
2695
|
const spaceScales = useMemo(() => {
|
|
2617
2696
|
// Here, we first compute the base scales, and then we insert a flat step for each split point:
|
|
2618
|
-
const baseScales = getScales(waypoints, { isProportional, yZoom }, minZoomMillimeterPerPx, maxZoomMillimeterPerPx);
|
|
2697
|
+
const baseScales = getScales(waypoints, { height, isProportional, yZoom }, minZoomMillimeterPerPx, maxZoomMillimeterPerPx);
|
|
2619
2698
|
if (!splitPoints)
|
|
2620
2699
|
return baseScales;
|
|
2621
2700
|
// Constant scale:
|
|
2622
2701
|
if (isProportional) {
|
|
2702
|
+
if (baseScales.length === 0)
|
|
2703
|
+
return baseScales;
|
|
2623
2704
|
const baseScale = baseScales[0];
|
|
2624
2705
|
const coefficient = 'coefficient' in baseScale && typeof baseScale.coefficient === 'number'
|
|
2625
2706
|
? baseScale.coefficient
|
|
2626
2707
|
: (baseScale.to - baseScale.from) / baseScale.size;
|
|
2627
2708
|
return splitPoints
|
|
2628
|
-
.flatMap(({ position, size: splitPointHeight }) =>
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2709
|
+
.flatMap(({ position, size: splitPointHeight }) => coefficient > 0
|
|
2710
|
+
? [
|
|
2711
|
+
{
|
|
2712
|
+
to: position,
|
|
2713
|
+
coefficient,
|
|
2714
|
+
},
|
|
2715
|
+
{
|
|
2716
|
+
to: position,
|
|
2717
|
+
size: splitPointHeight,
|
|
2718
|
+
},
|
|
2719
|
+
]
|
|
2720
|
+
: {
|
|
2634
2721
|
to: position,
|
|
2635
2722
|
size: splitPointHeight,
|
|
2636
|
-
}
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2723
|
+
})
|
|
2724
|
+
.concat(coefficient
|
|
2725
|
+
? {
|
|
2726
|
+
to: baseScales.at(-1).to,
|
|
2727
|
+
coefficient,
|
|
2728
|
+
}
|
|
2729
|
+
: []);
|
|
2642
2730
|
}
|
|
2643
2731
|
// Varying scales:
|
|
2644
2732
|
const allScales = [];
|
|
@@ -2665,7 +2753,7 @@ const useManchetteWithSpaceTimeChart = ({ waypoints, manchetteWithSpaceTimeChart
|
|
|
2665
2753
|
size: point.size,
|
|
2666
2754
|
});
|
|
2667
2755
|
});
|
|
2668
|
-
return sortBy(allScales, (scale) => scale.to + ('size' in scale ? Number.EPSILON : 0));
|
|
2756
|
+
return sortBy(allScales.filter((scale) => 'coefficient' in scale ? scale.coefficient > 0 : isFinite(scale.size)), (scale) => scale.to + ('size' in scale ? Number.EPSILON : 0));
|
|
2669
2757
|
}, [
|
|
2670
2758
|
waypoints,
|
|
2671
2759
|
height,
|
|
@@ -2675,26 +2763,23 @@ const useManchetteWithSpaceTimeChart = ({ waypoints, manchetteWithSpaceTimeChart
|
|
|
2675
2763
|
maxZoomMillimeterPerPx,
|
|
2676
2764
|
splitPoints,
|
|
2677
2765
|
]);
|
|
2678
|
-
const
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
yZoom,
|
|
2684
|
-
});
|
|
2685
|
-
return filteredWaypoints.filter((waypoint) => !splitPointPositions.has(waypoint.position));
|
|
2686
|
-
}, [splitPoints, waypoints, height, isProportional, yZoom]);
|
|
2766
|
+
const waypointsToDisplay = useMemo(() => selectWaypointsToDisplay(waypoints, {
|
|
2767
|
+
height,
|
|
2768
|
+
isProportional,
|
|
2769
|
+
yZoom,
|
|
2770
|
+
}), [waypoints, height, isProportional, yZoom]);
|
|
2687
2771
|
const { manchetteContents, manchetteHeight } = useMemo(() => {
|
|
2688
2772
|
const spaceScaleTree = spaceScalesToBinaryTree(spaceOrigin, spaceScales);
|
|
2689
2773
|
const getSpacePixel = getSpaceToPixel(0, spaceScaleTree);
|
|
2690
|
-
|
|
2691
|
-
if (
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
manchetteContents: waypointsWithoutSplitPoints,
|
|
2695
|
-
};
|
|
2774
|
+
let totalManchetteHeight = height - FOOTER_HEIGHT;
|
|
2775
|
+
if (spaceScales.length > 0) {
|
|
2776
|
+
totalManchetteHeight = Math.max(totalManchetteHeight, getSpacePixel(spaceScales.at(-1).to, true) + verticalPadding * 2);
|
|
2777
|
+
}
|
|
2696
2778
|
// Identify all manchette contents (split sections and waypoints):
|
|
2697
|
-
|
|
2779
|
+
const splitPointPositions = new Set(splitPoints.map((point) => point.position) || []);
|
|
2780
|
+
let allContents = waypointsToDisplay
|
|
2781
|
+
.filter((wp) => !splitPointPositions.has(wp.position))
|
|
2782
|
+
.map((wp) => ({
|
|
2698
2783
|
type: 'waypoint',
|
|
2699
2784
|
waypoint: wp,
|
|
2700
2785
|
position: wp.position,
|
|
@@ -2730,12 +2815,12 @@ const useManchetteWithSpaceTimeChart = ({ waypoints, manchetteWithSpaceTimeChart
|
|
|
2730
2815
|
const { split: { position }, } = content;
|
|
2731
2816
|
const top = getSpacePixel(position);
|
|
2732
2817
|
finalContents.push(React.createElement("div", { style: {
|
|
2733
|
-
// This
|
|
2734
|
-
// - Waypoints are positioned so that their lines (at
|
|
2818
|
+
// This verticalPadding correction is there because:
|
|
2819
|
+
// - Waypoints are positioned so that their lines (at verticalPadding pixels from
|
|
2735
2820
|
// the top) are aligned with SpaceTimeChart's space lines
|
|
2736
2821
|
// - Split points are positioned so that their top is aligned with SpaceTimeChart's
|
|
2737
2822
|
// space lines
|
|
2738
|
-
top: `${top +
|
|
2823
|
+
top: `${top + verticalPadding}px`,
|
|
2739
2824
|
height: `${getSpacePixel(position, true) - top}px`,
|
|
2740
2825
|
position: 'absolute',
|
|
2741
2826
|
width: '100%',
|
|
@@ -2748,7 +2833,7 @@ const useManchetteWithSpaceTimeChart = ({ waypoints, manchetteWithSpaceTimeChart
|
|
|
2748
2833
|
manchetteHeight: totalManchetteHeight,
|
|
2749
2834
|
manchetteContents: finalContents,
|
|
2750
2835
|
};
|
|
2751
|
-
}, [spaceOrigin, spaceScales,
|
|
2836
|
+
}, [spaceOrigin, spaceScales, verticalPadding, height, splitPoints, waypointsToDisplay]);
|
|
2752
2837
|
return useMemo(() => ({
|
|
2753
2838
|
manchetteProps: {
|
|
2754
2839
|
contents: manchetteContents,
|
|
@@ -2762,19 +2847,21 @@ const useManchetteWithSpaceTimeChart = ({ waypoints, manchetteWithSpaceTimeChart
|
|
|
2762
2847
|
yOffset,
|
|
2763
2848
|
},
|
|
2764
2849
|
spaceTimeChartProps: {
|
|
2765
|
-
operationalPoints:
|
|
2850
|
+
operationalPoints: waypointsToDisplay.map((waypoint) => ({
|
|
2766
2851
|
...waypoint,
|
|
2767
2852
|
importanceLevel: 1,
|
|
2768
2853
|
})),
|
|
2769
|
-
additionalChildren: splitPoints.map((sp) => sp.spaceTimeChartNode),
|
|
2854
|
+
additionalChildren: splitPoints.map((sp, i) => (React.createElement(Fragment, { key: i }, sp.spaceTimeChartNode))),
|
|
2855
|
+
hideTimeCaptions: !displayTimeCaptions,
|
|
2770
2856
|
timeScale: zoomValueToTimeScale(xZoom),
|
|
2771
2857
|
xOffset,
|
|
2772
|
-
yOffset: -yOffset +
|
|
2858
|
+
yOffset: -yOffset + verticalPadding,
|
|
2773
2859
|
timeOrigin,
|
|
2774
2860
|
spaceOrigin,
|
|
2775
2861
|
spaceScales,
|
|
2776
|
-
onZoom: ({ delta, position, }) => {
|
|
2862
|
+
onZoom: ({ delta, position, event, }) => {
|
|
2777
2863
|
if (isShiftPressed && !rect) {
|
|
2864
|
+
event.preventDefault();
|
|
2778
2865
|
handleXZoom(xZoom + delta, position.x);
|
|
2779
2866
|
}
|
|
2780
2867
|
},
|
|
@@ -2824,14 +2911,18 @@ const useManchetteWithSpaceTimeChart = ({ waypoints, manchetteWithSpaceTimeChart
|
|
|
2824
2911
|
}
|
|
2825
2912
|
const newState = { ...prev };
|
|
2826
2913
|
const { initialOffset } = panning;
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2914
|
+
const manchette = manchetteWithSpaceTimeChartRef.current;
|
|
2915
|
+
if (enableTimePan) {
|
|
2916
|
+
newState.xOffset = initialOffset.x + diff.x;
|
|
2917
|
+
}
|
|
2918
|
+
if (enableSpacePan) {
|
|
2919
|
+
let newYOffset = initialOffset.y - diff.y;
|
|
2920
|
+
newYOffset = Math.max(newYOffset, 0);
|
|
2921
|
+
if (manchette) {
|
|
2922
|
+
newYOffset = Math.min(newYOffset, manchette.scrollHeight - manchette.offsetHeight);
|
|
2923
|
+
manchette.scrollTop = newYOffset;
|
|
2924
|
+
}
|
|
2925
|
+
newState.yOffset = newYOffset;
|
|
2835
2926
|
}
|
|
2836
2927
|
return newState;
|
|
2837
2928
|
});
|
|
@@ -2856,13 +2947,14 @@ const useManchetteWithSpaceTimeChart = ({ waypoints, manchetteWithSpaceTimeChart
|
|
|
2856
2947
|
yZoom,
|
|
2857
2948
|
isProportional,
|
|
2858
2949
|
yOffset,
|
|
2859
|
-
|
|
2950
|
+
waypointsToDisplay,
|
|
2951
|
+
splitPoints,
|
|
2860
2952
|
xZoom,
|
|
2861
2953
|
xOffset,
|
|
2954
|
+
verticalPadding,
|
|
2862
2955
|
timeOrigin,
|
|
2863
2956
|
spaceOrigin,
|
|
2864
2957
|
spaceScales,
|
|
2865
|
-
splitPoints,
|
|
2866
2958
|
handleScroll,
|
|
2867
2959
|
handleXZoom,
|
|
2868
2960
|
toggleZoomMode,
|
|
@@ -2871,10 +2963,13 @@ const useManchetteWithSpaceTimeChart = ({ waypoints, manchetteWithSpaceTimeChart
|
|
|
2871
2963
|
minZoomMillimeterPerPx,
|
|
2872
2964
|
maxZoomMillimeterPerPx,
|
|
2873
2965
|
setTimeOrigin,
|
|
2966
|
+
displayTimeCaptions,
|
|
2874
2967
|
isShiftPressed,
|
|
2875
2968
|
panning,
|
|
2876
|
-
|
|
2969
|
+
enableTimePan,
|
|
2970
|
+
enableSpacePan,
|
|
2877
2971
|
canvasDrawingHeight,
|
|
2972
|
+
manchetteWithSpaceTimeChartRef,
|
|
2878
2973
|
]);
|
|
2879
2974
|
};
|
|
2880
2975
|
|
|
@@ -3513,7 +3608,7 @@ const drawSpeedLimits = ({ ctx, width, height, store }) => {
|
|
|
3513
3608
|
}
|
|
3514
3609
|
gradient.addColorStop(1, speedColor.alpha(0).hex());
|
|
3515
3610
|
ctx.fillStyle = gradient;
|
|
3516
|
-
ctx.rect(previousBoundaryX, speedY, currentBoundaryX - previousBoundaryX, -
|
|
3611
|
+
ctx.rect(previousBoundaryX, speedY, currentBoundaryX - previousBoundaryX, -GRADIENT_HEIGHT);
|
|
3517
3612
|
ctx.fill();
|
|
3518
3613
|
// Handle train length (only if next speed is higher than current speed)
|
|
3519
3614
|
let extendedBoundaryX = null;
|
|
@@ -4651,7 +4746,9 @@ const COLORS = {
|
|
|
4651
4746
|
GREY_50: 'rgb(121, 118, 113)',
|
|
4652
4747
|
GREY_60: 'rgb(92, 89, 85)',
|
|
4653
4748
|
GREY_80: 'rgb(49, 46, 43)',
|
|
4654
|
-
|
|
4749
|
+
MANCHETTE_BACKGROUND: '#f2f0e4',
|
|
4750
|
+
HOUR_BACKGROUND_1: '#faf9f5',
|
|
4751
|
+
HOUR_BACKGROUND_2: '#f2f0e4',
|
|
4655
4752
|
RAIL_TICK: 'rgb(33, 112, 185)',
|
|
4656
4753
|
REMAINING_TRAINS_BACKGROUND: 'rgba(0, 0, 0, 0.7)',
|
|
4657
4754
|
SELECTION_20: 'rgb(255, 242, 179)',
|
|
@@ -4743,7 +4840,7 @@ const Y_MEDIUM_POSITION_OFFSET = 14;
|
|
|
4743
4840
|
const ROTATE_VALUE = (-30 * Math.PI) / 180;
|
|
4744
4841
|
const { SANS: SANS$1, MONO } = FONTS;
|
|
4745
4842
|
const { WHITE_100: WHITE_100$2, GREY_50, GREY_60, GREY_80, SELECTION_20: SELECTION_20$1 } = COLORS;
|
|
4746
|
-
const drawOccupancyZonesTexts = ({ ctx, zone, arrivalTimePixel, departureTimePixel, yPosition, isThroughTrain,
|
|
4843
|
+
const drawOccupancyZonesTexts = ({ ctx, zone, arrivalTimePixel, departureTimePixel, yPosition, isThroughTrain, isSelected, }) => {
|
|
4747
4844
|
const zoneOccupancyLength = departureTimePixel - arrivalTimePixel - STROKE_WIDTH;
|
|
4748
4845
|
const isBelowBreakpoint = (breakpoint) => zoneOccupancyLength < BREAKPOINTS[breakpoint];
|
|
4749
4846
|
ctx.font = '400 10px IBM Plex Mono';
|
|
@@ -4765,11 +4862,11 @@ const drawOccupancyZonesTexts = ({ ctx, zone, arrivalTimePixel, departureTimePix
|
|
|
4765
4862
|
const xArrivalPosition = isBelowBreakpoint('small') ? 'right' : 'center';
|
|
4766
4863
|
const xDeparturePosition = isBelowBreakpoint('small') ? 'left' : 'center';
|
|
4767
4864
|
const textStroke = {
|
|
4768
|
-
color:
|
|
4865
|
+
color: isSelected ? 'transparent' : WHITE_100$2,
|
|
4769
4866
|
width: STROKE_WIDTH,
|
|
4770
4867
|
};
|
|
4771
4868
|
// train name
|
|
4772
|
-
if (
|
|
4869
|
+
if (isSelected) {
|
|
4773
4870
|
const { xSelectedTrainNameBackground, ySelectedTrainNameBackground } = isBelowBreakpoint('medium')
|
|
4774
4871
|
? {
|
|
4775
4872
|
xSelectedTrainNameBackground: xOriginTrainName - X_SELECTED_MEDIUM_PADDING,
|
|
@@ -4784,7 +4881,7 @@ const drawOccupancyZonesTexts = ({ ctx, zone, arrivalTimePixel, departureTimePix
|
|
|
4784
4881
|
ctx.rotate(ROTATE_VALUE);
|
|
4785
4882
|
ctx.fillStyle = SELECTION_20$1;
|
|
4786
4883
|
ctx.beginPath();
|
|
4787
|
-
ctx.roundRect(-
|
|
4884
|
+
ctx.roundRect(-X_BACKGROUND_PADDING$1, 0, nameTextLength + X_BACKGROUND_PADDING$1 * 2, Y_INITIAL_POSITION_OFFSET_BACKGROUND);
|
|
4788
4885
|
ctx.fill();
|
|
4789
4886
|
ctx.restore();
|
|
4790
4887
|
}
|
|
@@ -4803,7 +4900,9 @@ const drawOccupancyZonesTexts = ({ ctx, zone, arrivalTimePixel, departureTimePix
|
|
|
4803
4900
|
// arrival minutes & departure minutes
|
|
4804
4901
|
drawText({
|
|
4805
4902
|
ctx,
|
|
4806
|
-
text: zone.arrivalTime
|
|
4903
|
+
text: new Date(zone.arrivalTime)
|
|
4904
|
+
.getMinutes()
|
|
4905
|
+
.toLocaleString('fr-FR', { minimumIntegerDigits: 2 }),
|
|
4807
4906
|
x: isThroughTrain ? arrivalTimePixel - X_THROUGHTRAIN_OFFSET : arrivalTimePixel,
|
|
4808
4907
|
y: yPosition + MINUTES_TEXT_OFFSET,
|
|
4809
4908
|
color: GREY_80,
|
|
@@ -4815,7 +4914,9 @@ const drawOccupancyZonesTexts = ({ ctx, zone, arrivalTimePixel, departureTimePix
|
|
|
4815
4914
|
if (!isThroughTrain)
|
|
4816
4915
|
drawText({
|
|
4817
4916
|
ctx,
|
|
4818
|
-
text: zone.departureTime
|
|
4917
|
+
text: new Date(zone.departureTime)
|
|
4918
|
+
.getMinutes()
|
|
4919
|
+
.toLocaleString('fr-FR', { minimumIntegerDigits: 2 }),
|
|
4819
4920
|
x: departureTimePixel,
|
|
4820
4921
|
y: yPosition + MINUTES_TEXT_OFFSET,
|
|
4821
4922
|
color: GREY_80,
|
|
@@ -4854,15 +4955,13 @@ const { REMAINING_TRAINS_BACKGROUND, WHITE_100: WHITE_100$1, SELECTION_20 } = CO
|
|
|
4854
4955
|
const REMAINING_TRAINS_WIDTH = 70;
|
|
4855
4956
|
const REMAINING_TRAINS_HEIGHT = 24;
|
|
4856
4957
|
const REMAINING_TEXT_OFFSET = 12;
|
|
4857
|
-
const Y_OFFSET_INCREMENT = 4;
|
|
4858
|
-
const MAX_ZONES = 9;
|
|
4859
4958
|
const X_BACKGROUND_PADDING = 4;
|
|
4860
4959
|
const X_TROUGHTRAIN_BACKGROUND_PADDING = 8;
|
|
4861
4960
|
const BACKGROUND_HEIGHT = 40;
|
|
4862
4961
|
const SELECTED_TRAIN_ID_GRADIANT = 2;
|
|
4863
|
-
const drawDefaultZone = (
|
|
4962
|
+
const drawDefaultZone = (ctx, { x, y, width }) => {
|
|
4864
4963
|
ctx.beginPath();
|
|
4865
|
-
ctx.rect(
|
|
4964
|
+
ctx.rect(x, y, width, OCCUPANCY_ZONE_HEIGHT);
|
|
4866
4965
|
ctx.fill();
|
|
4867
4966
|
ctx.stroke();
|
|
4868
4967
|
};
|
|
@@ -4871,7 +4970,7 @@ const ARROW_OFFSET_Y = 1.5;
|
|
|
4871
4970
|
const ARROW_WIDTH = 4.5;
|
|
4872
4971
|
const ARROW_TOP_Y = 3.5;
|
|
4873
4972
|
const ARROW_BOTTOM_Y = 6.5;
|
|
4874
|
-
const drawThroughTrain = (
|
|
4973
|
+
const drawThroughTrain = (ctx, x, y) => {
|
|
4875
4974
|
// Through trains are materialized by converging arrows like the following ones
|
|
4876
4975
|
// ___
|
|
4877
4976
|
// \_/
|
|
@@ -4879,209 +4978,237 @@ const drawThroughTrain = ({ ctx, arrivalTimePixel, }) => {
|
|
|
4879
4978
|
// ‾‾‾
|
|
4880
4979
|
ctx.beginPath();
|
|
4881
4980
|
// draw the upper part
|
|
4882
|
-
ctx.moveTo(
|
|
4883
|
-
ctx.lineTo(
|
|
4884
|
-
ctx.lineTo(
|
|
4885
|
-
ctx.lineTo(
|
|
4981
|
+
ctx.moveTo(x - ARROW_OFFSET_X, y + ARROW_OFFSET_Y);
|
|
4982
|
+
ctx.lineTo(x - ARROW_WIDTH, y - ARROW_TOP_Y);
|
|
4983
|
+
ctx.lineTo(x + ARROW_WIDTH, y - ARROW_TOP_Y);
|
|
4984
|
+
ctx.lineTo(x + ARROW_OFFSET_X, y + ARROW_OFFSET_Y);
|
|
4886
4985
|
// draw the lower part
|
|
4887
|
-
ctx.lineTo(
|
|
4888
|
-
ctx.lineTo(
|
|
4889
|
-
ctx.lineTo(
|
|
4986
|
+
ctx.lineTo(x + ARROW_WIDTH, y + ARROW_BOTTOM_Y);
|
|
4987
|
+
ctx.lineTo(x - ARROW_WIDTH, y + ARROW_BOTTOM_Y);
|
|
4988
|
+
ctx.lineTo(x - ARROW_OFFSET_X, y + ARROW_OFFSET_Y);
|
|
4890
4989
|
ctx.fill();
|
|
4891
4990
|
// draw the white separator in the middle
|
|
4892
|
-
ctx.moveTo(
|
|
4893
|
-
ctx.lineTo(
|
|
4991
|
+
ctx.moveTo(x - ARROW_OFFSET_X, y + ARROW_OFFSET_Y);
|
|
4992
|
+
ctx.lineTo(x + ARROW_OFFSET_X, y + ARROW_OFFSET_Y);
|
|
4894
4993
|
ctx.stroke();
|
|
4895
4994
|
};
|
|
4896
|
-
const drawRemainingTrainsBox = ({
|
|
4897
|
-
const
|
|
4995
|
+
const drawRemainingTrainsBox = (ctx, { getTimePixel, getSpacePixel }, { time, position, yOffset, remainingTrainsNb, }) => {
|
|
4996
|
+
const x = getTimePixel(time);
|
|
4997
|
+
const y = getSpacePixel(position) + yOffset;
|
|
4998
|
+
const textY = y + OCCUPANCY_ZONE_Y_START - REMAINING_TEXT_OFFSET;
|
|
4898
4999
|
ctx.fillStyle = REMAINING_TRAINS_BACKGROUND;
|
|
4899
5000
|
ctx.beginPath();
|
|
4900
|
-
ctx.rect(
|
|
5001
|
+
ctx.rect(x - REMAINING_TRAINS_WIDTH / 2, textY, REMAINING_TRAINS_WIDTH, REMAINING_TRAINS_HEIGHT);
|
|
4901
5002
|
ctx.fill();
|
|
4902
5003
|
ctx.stroke();
|
|
4903
5004
|
ctx.fillStyle = WHITE_100$1;
|
|
4904
5005
|
ctx.font = SANS;
|
|
4905
5006
|
ctx.textAlign = 'center';
|
|
4906
5007
|
ctx.textBaseline = 'middle';
|
|
4907
|
-
ctx.fillText(`+${remainingTrainsNb} trains`,
|
|
5008
|
+
ctx.fillText(`+${remainingTrainsNb} trains`, x, textY + REMAINING_TRAINS_HEIGHT / 2);
|
|
4908
5009
|
};
|
|
4909
|
-
const drawOccupationZone = (
|
|
4910
|
-
|
|
4911
|
-
const trackN = CANVAS_PADDING + TRACK_HEIGHT_CONTAINER * index + yPosition;
|
|
4912
|
-
const canvasHeight = CANVAS_PADDING * 2 + TRACK_HEIGHT_CONTAINER * tracks.length;
|
|
4913
|
-
const trackPosition = canvasHeight - trackN;
|
|
4914
|
-
const arrowOffset = isThroughTrain ? 4 : 0;
|
|
4915
|
-
const xCheck = xMousePosition >= arrivalTimePixel - arrowOffset &&
|
|
4916
|
-
xMousePosition <= departureTimePixel + arrowOffset;
|
|
4917
|
-
const yCheck = Math.abs(yMousePosition) >= trackPosition - OCCUPANCY_ZONE_HEIGHT - 1 - arrowOffset &&
|
|
4918
|
-
Math.abs(yMousePosition) <= trackPosition + 1 + arrowOffset;
|
|
4919
|
-
if (xCheck && yCheck) {
|
|
4920
|
-
setSelectedTrainId(zone.id);
|
|
4921
|
-
currentSelectedTrainId = zone.id;
|
|
4922
|
-
}
|
|
5010
|
+
const drawOccupationZone = (ctx, stcContext, { zone, yOffset, position, isSelected, }) => {
|
|
5011
|
+
const isThroughTrain = zone.arrivalTime === zone.departureTime;
|
|
4923
5012
|
ctx.fillStyle = zone.color;
|
|
4924
5013
|
ctx.strokeStyle = WHITE_100$1;
|
|
4925
5014
|
ctx.lineJoin = 'round';
|
|
4926
5015
|
ctx.lineCap = 'round';
|
|
4927
5016
|
ctx.font = '400 10px IBM Plex Mono';
|
|
4928
|
-
|
|
5017
|
+
const { getTimePixel, getSpacePixel } = stcContext;
|
|
5018
|
+
const yStart = getCrispLineCoordinate(getSpacePixel(position), BACKGROUND_HEIGHT);
|
|
5019
|
+
const y = yStart + yOffset;
|
|
5020
|
+
const yEnd = getSpacePixel(position, true);
|
|
5021
|
+
const arrivalTimePixel = getTimePixel(zone.arrivalTime);
|
|
5022
|
+
const departureTimePixel = getTimePixel(zone.departureTime);
|
|
5023
|
+
if (isSelected) {
|
|
4929
5024
|
const extraWidth = isThroughTrain ? X_TROUGHTRAIN_BACKGROUND_PADDING : X_BACKGROUND_PADDING;
|
|
4930
5025
|
const originTextLength = ctx.measureText(zone.originStation || '--').width;
|
|
4931
5026
|
const destinationTextLength = ctx.measureText(zone.destinationStation || '--').width;
|
|
4932
|
-
ctx.save();
|
|
4933
5027
|
ctx.fillStyle = SELECTION_20;
|
|
4934
5028
|
ctx.beginPath();
|
|
4935
|
-
ctx.roundRect(arrivalTimePixel - originTextLength - extraWidth,
|
|
5029
|
+
ctx.roundRect(arrivalTimePixel - originTextLength - extraWidth, y - BACKGROUND_HEIGHT / 2, departureTimePixel -
|
|
4936
5030
|
arrivalTimePixel +
|
|
4937
5031
|
originTextLength +
|
|
4938
5032
|
destinationTextLength +
|
|
4939
5033
|
extraWidth * 2, BACKGROUND_HEIGHT, SELECTED_TRAIN_ID_GRADIANT);
|
|
4940
5034
|
ctx.fill();
|
|
4941
|
-
ctx.restore();
|
|
4942
5035
|
}
|
|
5036
|
+
ctx.fillStyle = zone.color;
|
|
4943
5037
|
if (isThroughTrain) {
|
|
4944
|
-
drawThroughTrain(
|
|
5038
|
+
drawThroughTrain(ctx, arrivalTimePixel, y);
|
|
4945
5039
|
}
|
|
4946
5040
|
else {
|
|
4947
|
-
drawDefaultZone(
|
|
5041
|
+
drawDefaultZone(ctx, {
|
|
5042
|
+
x: arrivalTimePixel,
|
|
5043
|
+
y,
|
|
5044
|
+
width: departureTimePixel - arrivalTimePixel,
|
|
5045
|
+
});
|
|
4948
5046
|
}
|
|
5047
|
+
// Draw dashed lines linking trains tracks occupancy to their paths on the SpaceTimeChart (when relevant):
|
|
5048
|
+
ctx.strokeStyle = zone.color;
|
|
5049
|
+
ctx.lineWidth = 1;
|
|
5050
|
+
ctx.setLineDash([1, 4]);
|
|
5051
|
+
if (zone.arrivalDirection) {
|
|
5052
|
+
ctx.beginPath();
|
|
5053
|
+
ctx.moveTo(arrivalTimePixel, y);
|
|
5054
|
+
ctx.lineTo(arrivalTimePixel, zone.arrivalDirection === 'up' ? yStart : yEnd);
|
|
5055
|
+
ctx.stroke();
|
|
5056
|
+
}
|
|
5057
|
+
if (zone.departureDirection) {
|
|
5058
|
+
ctx.beginPath();
|
|
5059
|
+
ctx.moveTo(departureTimePixel, y);
|
|
5060
|
+
ctx.lineTo(departureTimePixel, zone.departureDirection === 'up' ? yStart : yEnd);
|
|
5061
|
+
ctx.stroke();
|
|
5062
|
+
}
|
|
5063
|
+
ctx.setLineDash([]);
|
|
5064
|
+
// Draw texts:
|
|
4949
5065
|
drawOccupancyZonesTexts({
|
|
4950
5066
|
ctx,
|
|
4951
5067
|
zone,
|
|
4952
5068
|
arrivalTimePixel,
|
|
4953
5069
|
departureTimePixel,
|
|
4954
|
-
yPosition,
|
|
4955
5070
|
isThroughTrain,
|
|
4956
|
-
|
|
5071
|
+
yPosition: y,
|
|
5072
|
+
isSelected,
|
|
4957
5073
|
});
|
|
4958
5074
|
};
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
departureTimePixel,
|
|
5005
|
-
yPosition,
|
|
5006
|
-
isThroughTrain,
|
|
5007
|
-
selectedTrainId,
|
|
5008
|
-
setSelectedTrainId,
|
|
5009
|
-
index,
|
|
5010
|
-
xMousePosition,
|
|
5011
|
-
yMousePosition,
|
|
5012
|
-
});
|
|
5013
|
-
zoneIndex++;
|
|
5014
|
-
continue;
|
|
5015
|
-
}
|
|
5016
|
-
if (zoneCounter < MAX_ZONES) {
|
|
5075
|
+
|
|
5076
|
+
const Y_OFFSET_INCREMENT = 4;
|
|
5077
|
+
const MAX_ZONES = 9;
|
|
5078
|
+
const OccupancyZonesLayer = ({ tracks, occupancyZones, position, topPadding, selectedTrainId, }) => {
|
|
5079
|
+
const instructionsToDraw = useMemo(() => {
|
|
5080
|
+
const instructions = [];
|
|
5081
|
+
if (!tracks || !occupancyZones || occupancyZones.length === 0)
|
|
5082
|
+
return instructions;
|
|
5083
|
+
const sortedOccupancyZones = occupancyZones.sort((a, b) => a.arrivalTime - b.arrivalTime);
|
|
5084
|
+
tracks.forEach((track, index) => {
|
|
5085
|
+
const trackY = topPadding + CANVAS_PADDING + index * TRACK_HEIGHT_CONTAINER;
|
|
5086
|
+
const filteredOccupancyZones = sortedOccupancyZones.filter((zone) => zone.trackId === track.id);
|
|
5087
|
+
let primaryArrivalTime = 0;
|
|
5088
|
+
let lastDepartureTime = 0;
|
|
5089
|
+
let yPosition = OCCUPANCY_ZONE_Y_START;
|
|
5090
|
+
let yOffset = Y_OFFSET_INCREMENT;
|
|
5091
|
+
let zoneCounter = 0;
|
|
5092
|
+
let zoneIndex = 0;
|
|
5093
|
+
while (zoneIndex < filteredOccupancyZones.length) {
|
|
5094
|
+
const zone = filteredOccupancyZones[zoneIndex];
|
|
5095
|
+
const { arrivalTime, departureTime } = zone;
|
|
5096
|
+
// * if the zone is not overlapping with any previous one, draw it in the center of the track
|
|
5097
|
+
// * and reset the primary values
|
|
5098
|
+
// *
|
|
5099
|
+
// * if the zone is overlapping with the previous one, draw it below or above the previous one
|
|
5100
|
+
// * depending on the overlapping counter
|
|
5101
|
+
// *
|
|
5102
|
+
// * if the zone is overlapping with the previous one and the counter is higher than the max zones
|
|
5103
|
+
// * draw the remaining trains box
|
|
5104
|
+
// *
|
|
5105
|
+
if (arrivalTime > lastDepartureTime) {
|
|
5106
|
+
// reset to initial value if the zone is not overlapping
|
|
5107
|
+
yPosition = OCCUPANCY_ZONE_Y_START;
|
|
5108
|
+
primaryArrivalTime = arrivalTime;
|
|
5109
|
+
lastDepartureTime = departureTime;
|
|
5110
|
+
yOffset = Y_OFFSET_INCREMENT;
|
|
5111
|
+
zoneCounter = 1;
|
|
5112
|
+
instructions.push({
|
|
5113
|
+
type: 'occupancyZone',
|
|
5114
|
+
zone,
|
|
5115
|
+
offsetY: trackY + yPosition,
|
|
5116
|
+
isSelected: zone.trainId === selectedTrainId,
|
|
5117
|
+
});
|
|
5118
|
+
zoneIndex++;
|
|
5119
|
+
}
|
|
5017
5120
|
// if so and it's an even index, move it to the bottom, if it's an odd index, move it to the top
|
|
5018
|
-
if (
|
|
5019
|
-
if (
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5121
|
+
else if (zoneCounter < MAX_ZONES) {
|
|
5122
|
+
if (arrivalTime >= primaryArrivalTime) {
|
|
5123
|
+
if (zoneCounter % 2 === 0) {
|
|
5124
|
+
yPosition -= yOffset;
|
|
5125
|
+
}
|
|
5126
|
+
else {
|
|
5127
|
+
yPosition += yOffset;
|
|
5128
|
+
}
|
|
5024
5129
|
}
|
|
5130
|
+
// update the last departure time if the current zone is longer
|
|
5131
|
+
if (departureTime >= lastDepartureTime)
|
|
5132
|
+
lastDepartureTime = departureTime;
|
|
5133
|
+
instructions.push({
|
|
5134
|
+
type: 'occupancyZone',
|
|
5135
|
+
zone,
|
|
5136
|
+
offsetY: trackY + yPosition,
|
|
5137
|
+
isSelected: zone.trainId === selectedTrainId,
|
|
5138
|
+
});
|
|
5139
|
+
zoneCounter++;
|
|
5140
|
+
yOffset += Y_OFFSET_INCREMENT;
|
|
5141
|
+
zoneIndex++;
|
|
5142
|
+
}
|
|
5143
|
+
// else, if there are too much trains:
|
|
5144
|
+
else {
|
|
5145
|
+
const nextIndex = filteredOccupancyZones.findIndex((filteredZone, i) => i > zoneIndex && filteredZone.arrivalTime >= lastDepartureTime);
|
|
5146
|
+
const remainingTrainsNb = nextIndex - zoneIndex;
|
|
5147
|
+
instructions.push({
|
|
5148
|
+
type: 'remainingTrains',
|
|
5149
|
+
amount: remainingTrainsNb,
|
|
5150
|
+
time: (arrivalTime + departureTime) / 2,
|
|
5151
|
+
offsetY: trackY,
|
|
5152
|
+
});
|
|
5153
|
+
zoneIndex += remainingTrainsNb;
|
|
5025
5154
|
}
|
|
5026
|
-
// update the last departure time if the current zone is longer
|
|
5027
|
-
if (departureTimePixel >= lastDepartureTimePixel)
|
|
5028
|
-
lastDepartureTimePixel = departureTimePixel;
|
|
5029
|
-
drawOccupationZone({
|
|
5030
|
-
ctx,
|
|
5031
|
-
zone,
|
|
5032
|
-
tracks,
|
|
5033
|
-
arrivalTimePixel,
|
|
5034
|
-
departureTimePixel,
|
|
5035
|
-
yPosition,
|
|
5036
|
-
isThroughTrain,
|
|
5037
|
-
selectedTrainId,
|
|
5038
|
-
setSelectedTrainId,
|
|
5039
|
-
index,
|
|
5040
|
-
xMousePosition,
|
|
5041
|
-
yMousePosition,
|
|
5042
|
-
});
|
|
5043
|
-
zoneCounter++;
|
|
5044
|
-
yOffset += Y_OFFSET_INCREMENT;
|
|
5045
|
-
zoneIndex++;
|
|
5046
|
-
continue;
|
|
5047
5155
|
}
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5156
|
+
});
|
|
5157
|
+
return sortBy(instructions, (instruction) => instruction.type === 'occupancyZone' && instruction.isSelected ? 0 : 1);
|
|
5158
|
+
}, [occupancyZones, selectedTrainId, topPadding, tracks]);
|
|
5159
|
+
const drawingFunction = useCallback((ctx, stcContext) => {
|
|
5160
|
+
instructionsToDraw.forEach((instruction) => {
|
|
5161
|
+
switch (instruction.type) {
|
|
5162
|
+
case 'occupancyZone':
|
|
5163
|
+
drawOccupationZone(ctx, stcContext, {
|
|
5164
|
+
zone: instruction.zone,
|
|
5165
|
+
position,
|
|
5166
|
+
yOffset: instruction.offsetY,
|
|
5167
|
+
isSelected: instruction.isSelected,
|
|
5168
|
+
});
|
|
5169
|
+
break;
|
|
5170
|
+
case 'remainingTrains':
|
|
5171
|
+
drawRemainingTrainsBox(ctx, stcContext, {
|
|
5172
|
+
position,
|
|
5173
|
+
time: instruction.time,
|
|
5174
|
+
yOffset: instruction.offsetY,
|
|
5175
|
+
remainingTrainsNb: instruction.amount,
|
|
5176
|
+
});
|
|
5177
|
+
break;
|
|
5178
|
+
}
|
|
5179
|
+
});
|
|
5180
|
+
}, [position, instructionsToDraw]);
|
|
5181
|
+
const pickingFunction = useCallback((imageData, { registerPickingElement, getTimePixel, getSpacePixel }, scalingRatio) => {
|
|
5182
|
+
const flatStepOffsetY = getSpacePixel(position);
|
|
5183
|
+
instructionsToDraw.forEach((instruction) => {
|
|
5184
|
+
if (instruction.type === 'occupancyZone') {
|
|
5185
|
+
const x = getTimePixel(instruction.zone.arrivalTime);
|
|
5186
|
+
const y = instruction.offsetY + flatStepOffsetY;
|
|
5187
|
+
const width = getTimePixel(instruction.zone.departureTime) - x;
|
|
5188
|
+
const height = OCCUPANCY_ZONE_HEIGHT;
|
|
5189
|
+
const margin = 6;
|
|
5190
|
+
const pickingElement = {
|
|
5191
|
+
type: 'occupancyZone',
|
|
5192
|
+
trainId: instruction.zone.trainId,
|
|
5193
|
+
};
|
|
5194
|
+
const pickingIndex = registerPickingElement(pickingElement);
|
|
5195
|
+
const color = hexToRgb(indexToColor(pickingIndex));
|
|
5196
|
+
drawAliasedRect(imageData, { x: x - margin, y: y - margin }, width + 2 * margin, height + 2 * margin, color, scalingRatio);
|
|
5197
|
+
}
|
|
5198
|
+
});
|
|
5199
|
+
}, [position, instructionsToDraw]);
|
|
5200
|
+
usePicking('overlay', pickingFunction);
|
|
5201
|
+
useDraw('overlay', drawingFunction);
|
|
5077
5202
|
return null;
|
|
5078
5203
|
};
|
|
5079
5204
|
|
|
5080
|
-
const { WHITE_50, GREY_20, RAIL_TICK } = COLORS;
|
|
5205
|
+
const { WHITE_100, WHITE_50, GREY_20, RAIL_TICK } = COLORS;
|
|
5081
5206
|
const drawRails = ({ xStart, yStart, width, stroke = GREY_20, ctx, }) => {
|
|
5082
|
-
ctx.
|
|
5207
|
+
ctx.fillStyle = WHITE_100;
|
|
5208
|
+
ctx.fillRect(xStart, yStart, width, 9);
|
|
5083
5209
|
ctx.fillStyle = WHITE_50;
|
|
5084
5210
|
ctx.strokeStyle = stroke;
|
|
5211
|
+
ctx.lineWidth = 1;
|
|
5085
5212
|
ctx.beginPath();
|
|
5086
5213
|
ctx.rect(xStart, yStart, width, 8);
|
|
5087
5214
|
ctx.fill();
|
|
@@ -5090,6 +5217,7 @@ const drawRails = ({ xStart, yStart, width, stroke = GREY_20, ctx, }) => {
|
|
|
5090
5217
|
const drawTick = ({ ctx, xStart, yStart, ticks, stroke, }) => {
|
|
5091
5218
|
const sumTicks = sum(ticks) / 2;
|
|
5092
5219
|
ctx.strokeStyle = stroke;
|
|
5220
|
+
ctx.lineWidth = 1;
|
|
5093
5221
|
ctx.beginPath();
|
|
5094
5222
|
ctx.setLineDash(ticks);
|
|
5095
5223
|
ctx.moveTo(xStart, yStart - sumTicks);
|
|
@@ -5115,33 +5243,30 @@ const drawTrack = ({ ctx, width, getTimePixel, labelMarks }) => {
|
|
|
5115
5243
|
ctx.restore();
|
|
5116
5244
|
};
|
|
5117
5245
|
|
|
5118
|
-
const {
|
|
5119
|
-
const
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
const
|
|
5127
|
-
ctx.clearRect(0, 0, width, height);
|
|
5128
|
-
ctx.save();
|
|
5129
|
-
const minT = timeOrigin - timeScale * timePixelOffset;
|
|
5130
|
-
const maxT = minT + timeScale * width;
|
|
5131
|
-
const pixelsPerMinute = (1 / timeScale) * 60_000;
|
|
5246
|
+
const { HOUR_BACKGROUND_1, HOUR_BACKGROUND_2 } = COLORS;
|
|
5247
|
+
const drawTracks = (ctx, stcContext, { position, tracks, drawBorders, topPadding = 0, }) => {
|
|
5248
|
+
const { width, getSpacePixel, getTime, getTimePixel, timeScale, theme: { breakpoints, timeRanges }, } = stcContext;
|
|
5249
|
+
const yStart = getSpacePixel(position);
|
|
5250
|
+
const yEnd = getSpacePixel(position, true);
|
|
5251
|
+
const flatStepHeight = yEnd - yStart;
|
|
5252
|
+
const timeStart = getTime(0);
|
|
5253
|
+
const timeEnd = getTime(width);
|
|
5254
|
+
const pixelsPerMinute = (1 / timeScale) * MINUTE;
|
|
5132
5255
|
const labelLevels = getLabelLevels(breakpoints, pixelsPerMinute, TICKS_PRIORITIES);
|
|
5133
|
-
const labelMarks = getLabelMarks(timeRanges,
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
}
|
|
5256
|
+
const labelMarks = getLabelMarks(timeRanges, timeStart, timeEnd, labelLevels);
|
|
5257
|
+
// Draw backgrounds:
|
|
5258
|
+
let hours = Math.floor(timeStart / HOUR);
|
|
5259
|
+
const hourEnd = timeEnd / HOUR;
|
|
5260
|
+
while (hours < hourEnd) {
|
|
5261
|
+
const x = getTimePixel(hours * HOUR);
|
|
5262
|
+
const w = getTimePixel((hours + 1) * HOUR) - x;
|
|
5263
|
+
ctx.fillStyle = hours % 2 ? HOUR_BACKGROUND_1 : HOUR_BACKGROUND_2;
|
|
5264
|
+
ctx.fillRect(x, yStart, w, flatStepHeight);
|
|
5265
|
+
hours++;
|
|
5144
5266
|
}
|
|
5267
|
+
// Draw actual tracks:
|
|
5268
|
+
ctx.save();
|
|
5269
|
+
ctx.translate(0, yStart + topPadding);
|
|
5145
5270
|
tracks?.forEach((_, index) => {
|
|
5146
5271
|
const trackTranslate = index === 0 ? CANVAS_PADDING : TRACK_HEIGHT_CONTAINER;
|
|
5147
5272
|
ctx.translate(0, trackTranslate);
|
|
@@ -5153,38 +5278,116 @@ const drawTracks = ({ ctx, width, height, tracks, timeOrigin, timePixelOffset, g
|
|
|
5153
5278
|
});
|
|
5154
5279
|
});
|
|
5155
5280
|
ctx.restore();
|
|
5281
|
+
// Draw borders:
|
|
5282
|
+
if (drawBorders) {
|
|
5283
|
+
const externalBorderWidth = 1;
|
|
5284
|
+
const internalBorderWidth = 2;
|
|
5285
|
+
const fullBorderWidth = externalBorderWidth + internalBorderWidth;
|
|
5286
|
+
const yStartCrisp = Math.round(yStart);
|
|
5287
|
+
const yEndCrisp = Math.round(yEnd);
|
|
5288
|
+
ctx.fillStyle = GREY_50$2;
|
|
5289
|
+
ctx.fillRect(0, yStartCrisp, width, externalBorderWidth);
|
|
5290
|
+
ctx.fillRect(0, yEndCrisp - externalBorderWidth, width, externalBorderWidth);
|
|
5291
|
+
ctx.fillStyle = GREY_50$2;
|
|
5292
|
+
ctx.globalAlpha = 0.15;
|
|
5293
|
+
ctx.fillRect(0, yStartCrisp + externalBorderWidth, width, internalBorderWidth);
|
|
5294
|
+
ctx.fillRect(0, yEndCrisp - fullBorderWidth, width, internalBorderWidth);
|
|
5295
|
+
ctx.globalAlpha = 1;
|
|
5296
|
+
}
|
|
5156
5297
|
};
|
|
5157
5298
|
|
|
5158
|
-
const TracksLayer = ({
|
|
5159
|
-
const drawingFunction = useCallback((ctx,
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
width: trackOccupancyWidth,
|
|
5164
|
-
height: trackOccupancyHeight,
|
|
5165
|
-
tracks,
|
|
5166
|
-
timeOrigin,
|
|
5167
|
-
timePixelOffset,
|
|
5168
|
-
getTimePixel,
|
|
5169
|
-
timeRanges,
|
|
5170
|
-
breakpoints,
|
|
5171
|
-
timeScale,
|
|
5172
|
-
});
|
|
5173
|
-
}, []);
|
|
5174
|
-
useDraw('background', drawingFunction);
|
|
5299
|
+
const TracksLayer = ({ tracks, position, topPadding, drawBorders, }) => {
|
|
5300
|
+
const drawingFunction = useCallback((ctx, stcContext) => {
|
|
5301
|
+
drawTracks(ctx, stcContext, { position, topPadding, tracks, drawBorders });
|
|
5302
|
+
}, [drawBorders, position, topPadding, tracks]);
|
|
5303
|
+
useDraw('overlay', drawingFunction);
|
|
5175
5304
|
return null;
|
|
5176
5305
|
};
|
|
5177
5306
|
|
|
5178
|
-
const
|
|
5179
|
-
|
|
5180
|
-
React.createElement(
|
|
5307
|
+
const CloseButton = ({ position, onClose }) => {
|
|
5308
|
+
const { getSpacePixel } = useContext(SpaceTimeChartContext);
|
|
5309
|
+
return (React.createElement("button", { className: "close-track-occupancy-panel", onClick: () => onClose(), style: {
|
|
5310
|
+
top: getSpacePixel(position),
|
|
5311
|
+
} },
|
|
5312
|
+
React.createElement("span", null,
|
|
5313
|
+
React.createElement(X, null))));
|
|
5314
|
+
};
|
|
5315
|
+
const TrackOccupancyCanvas = ({ position, tracks, occupancyZones, selectedTrainId, onClose, topPadding = 0, hideBorders = false, }) => (React.createElement(React.Fragment, null,
|
|
5316
|
+
React.createElement(TracksLayer, { position: position, tracks: tracks, topPadding: topPadding, drawBorders: !hideBorders }),
|
|
5317
|
+
React.createElement(OccupancyZonesLayer, { tracks: tracks, position: position, topPadding: topPadding, occupancyZones: occupancyZones, selectedTrainId: selectedTrainId }),
|
|
5318
|
+
onClose && React.createElement(CloseButton, { position: position, onClose: onClose })));
|
|
5319
|
+
|
|
5320
|
+
const TrackOccupancyManchette = ({ tracks, children }) => (React.createElement("div", { className: "track-occupancy-manchette" },
|
|
5321
|
+
children,
|
|
5322
|
+
tracks.map((track) => (
|
|
5323
|
+
// height is shared between manchette and canvas components
|
|
5324
|
+
React.createElement("div", { className: "track", key: track.id, style: { height: TRACK_HEIGHT_CONTAINER } },
|
|
5325
|
+
React.createElement("span", { className: "track-line" }, track.line),
|
|
5326
|
+
React.createElement("div", { className: "track-name" }, track.name),
|
|
5327
|
+
React.createElement("div", { className: "track-rail" }))))));
|
|
5181
5328
|
|
|
5182
|
-
const
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5329
|
+
const TrackOccupancyStandalone = ({ tracks, occupancyZones, selectedTrainId, onSelectedTrainIdChange, height = TRACK_HEIGHT_CONTAINER * tracks.length + DEFAULT_THEME.timeCaptionsSize, }) => {
|
|
5330
|
+
const manchetteWithSpaceTimeChartRef = useRef(null);
|
|
5331
|
+
const spaceTimeChartRef = useRef(null);
|
|
5332
|
+
const defaultTimeOrigin = useMemo(() => {
|
|
5333
|
+
const minTime = Math.min(...(occupancyZones.map((zone) => zone.arrivalTime) || Date.now()));
|
|
5334
|
+
// Take first round hour before minTime:
|
|
5335
|
+
return Math.floor(minTime / HOUR) * HOUR;
|
|
5336
|
+
}, [occupancyZones]);
|
|
5337
|
+
// To make SpaceTimeChart and Manchette work, we have to provide them some dummy data:
|
|
5338
|
+
const waypoints = useMemo(() => [
|
|
5339
|
+
{
|
|
5340
|
+
id: 'FAKE_WAYPOINT_1',
|
|
5341
|
+
position: 0,
|
|
5342
|
+
},
|
|
5343
|
+
], []);
|
|
5344
|
+
const splitPoints = useMemo(() => [
|
|
5345
|
+
{
|
|
5346
|
+
id: 'ACTUAL_TRACK_OCCUPANCY_DIAGRAM',
|
|
5347
|
+
position: 0,
|
|
5348
|
+
size: Math.max(height, tracks.length * TRACK_HEIGHT_CONTAINER + DEFAULT_THEME.timeCaptionsSize),
|
|
5349
|
+
spaceTimeChartNode: (React.createElement(TrackOccupancyCanvas, { position: 0, tracks: tracks, occupancyZones: occupancyZones, selectedTrainId: selectedTrainId, hideBorders: true })),
|
|
5350
|
+
manchetteNode: React.createElement(TrackOccupancyManchette, { tracks: tracks }),
|
|
5351
|
+
},
|
|
5352
|
+
], [height, tracks, occupancyZones, selectedTrainId]);
|
|
5353
|
+
/**
|
|
5354
|
+
* We now use useManchetteWithSpaceTimeChart, to get proper pan along the time (and space axis if
|
|
5355
|
+
* the container is smaller than the contents):
|
|
5356
|
+
*/
|
|
5357
|
+
const { manchetteProps, spaceTimeChartProps, handleScroll } = useManchetteWithSpaceTimeChart({
|
|
5358
|
+
waypoints,
|
|
5359
|
+
manchetteWithSpaceTimeChartRef,
|
|
5360
|
+
height,
|
|
5361
|
+
spaceTimeChartRef,
|
|
5362
|
+
splitPoints,
|
|
5363
|
+
defaultTimeOrigin,
|
|
5364
|
+
verticalPadding: 0,
|
|
5365
|
+
options: {
|
|
5366
|
+
displayTimeCaptions: true,
|
|
5367
|
+
enableTimePan: true,
|
|
5368
|
+
enableSpacePan: true,
|
|
5369
|
+
enableTimeZoom: false,
|
|
5370
|
+
},
|
|
5371
|
+
});
|
|
5372
|
+
return (React.createElement("div", { className: "track-occupancy-standalone flex flex-col" },
|
|
5373
|
+
React.createElement("div", { className: "bg-ambientB-5 flex flex-col justify-center main-container-header grow-0 shrink-0" },
|
|
5374
|
+
React.createElement(KebabHorizontal, null)),
|
|
5375
|
+
React.createElement("div", { className: "manchette-space-time-chart-wrapper", style: { maxHeight: height } },
|
|
5376
|
+
React.createElement("div", { ref: manchetteWithSpaceTimeChartRef, className: "manchette flex h-100", onScroll: handleScroll, style: { height } },
|
|
5377
|
+
React.createElement(Manchette, { ...manchetteProps }),
|
|
5378
|
+
React.createElement("div", { className: "space-time-chart-container w-full sticky", ref: spaceTimeChartRef },
|
|
5379
|
+
React.createElement(SpaceTimeChart, { className: "inset-0 absolute h-full", ...spaceTimeChartProps, onClick: onSelectedTrainIdChange &&
|
|
5380
|
+
(({ hoveredItem }) => {
|
|
5381
|
+
if (hoveredItem?.layer === 'overlay' &&
|
|
5382
|
+
hoveredItem.element.type === 'occupancyZone') {
|
|
5383
|
+
const newId = hoveredItem.element.trainId;
|
|
5384
|
+
onSelectedTrainIdChange(newId === selectedTrainId ? undefined : newId);
|
|
5385
|
+
}
|
|
5386
|
+
else {
|
|
5387
|
+
onSelectedTrainIdChange(undefined);
|
|
5388
|
+
}
|
|
5389
|
+
}) }))))));
|
|
5390
|
+
};
|
|
5188
5391
|
|
|
5189
|
-
export { CanvasContext, ConflictLayer, ConflictTooltip, DEFAULT_LEVEL, DEFAULT_THEME, DEFAULT_ZOOM_MS_PER_PX, Manchette, ManchetteWithSpaceTimeChart, MouseContext, OccupancyBlockLayer, PathLayer, PatternRect, Quadrilateral, SpaceTimeChart, SpaceTimeChartContext, SpeedSpaceChart, TimeCaptions, Tooltip$1 as Tooltip, TrackOccupancyCanvas, TrackOccupancyManchette, WorkScheduleLayer, ZoomRect, getCrispLineCoordinate, getSpaceAtTime, isConflictPickingElement, isInteractiveWaypoint, isPathOnScreen, isPointPickingElement, isSegmentPickingElement, positionMmToKm, timeScaleToZoomValue, useDraw, useManchetteWithSpaceTimeChart, usePaths, usePicking };
|
|
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 };
|
|
5190
5393
|
//# sourceMappingURL=index.esm.js.map
|