@osrd-project/ui-charts 0.0.68

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.
Files changed (132) hide show
  1. package/README.md +63 -0
  2. package/dist/index.d.ts +5 -0
  3. package/dist/index.esm.js +2 -0
  4. package/dist/index.esm.js.map +1 -0
  5. package/dist/manchette/components/Manchette.d.ts +16 -0
  6. package/dist/manchette/components/ManchetteWithSpaceTimeChart.d.ts +22 -0
  7. package/dist/manchette/components/Waypoint.d.ts +10 -0
  8. package/dist/manchette/components/WaypointList.d.ts +9 -0
  9. package/dist/manchette/consts.d.ts +15 -0
  10. package/dist/manchette/hooks/useManchetteWithSpaceTimeChart.d.ts +66 -0
  11. package/dist/manchette/hooks/usePaths.d.ts +13 -0
  12. package/dist/manchette/index.d.ts +9 -0
  13. package/dist/manchette/types.d.ts +26 -0
  14. package/dist/manchette/utils/__tests__/helpers.spec.d.ts +1 -0
  15. package/dist/manchette/utils/helpers.d.ts +31 -0
  16. package/dist/manchette/utils/index.d.ts +12 -0
  17. package/dist/spaceTimeChart/__tests__/canvas.spec.d.ts +1 -0
  18. package/dist/spaceTimeChart/__tests__/geometry.spec.d.ts +1 -0
  19. package/dist/spaceTimeChart/__tests__/paths.spec.d.ts +1 -0
  20. package/dist/spaceTimeChart/__tests__/scales.spec.d.ts +1 -0
  21. package/dist/spaceTimeChart/__tests__/snapping.spec.d.ts +1 -0
  22. package/dist/spaceTimeChart/components/ConflictLayer.d.ts +16 -0
  23. package/dist/spaceTimeChart/components/ConflictTooltip.d.ts +13 -0
  24. package/dist/spaceTimeChart/components/OccupancyBlockLayer.d.ts +11 -0
  25. package/dist/spaceTimeChart/components/PathLayer.d.ts +36 -0
  26. package/dist/spaceTimeChart/components/PatternRect.d.ts +8 -0
  27. package/dist/spaceTimeChart/components/SpaceGraduations.d.ts +2 -0
  28. package/dist/spaceTimeChart/components/SpaceTimeChart.d.ts +3 -0
  29. package/dist/spaceTimeChart/components/TimeCaptions.d.ts +3 -0
  30. package/dist/spaceTimeChart/components/TimeGraduations.d.ts +2 -0
  31. package/dist/spaceTimeChart/components/WorkScheduleLayer.d.ts +14 -0
  32. package/dist/spaceTimeChart/components/ZoomRect.d.ts +2 -0
  33. package/dist/spaceTimeChart/config.d.ts +4 -0
  34. package/dist/spaceTimeChart/hooks/useCanvas.d.ts +19 -0
  35. package/dist/spaceTimeChart/hooks/useDevicePixelRatio.d.ts +1 -0
  36. package/dist/spaceTimeChart/hooks/useMouseInteractions.d.ts +8 -0
  37. package/dist/spaceTimeChart/hooks/useMouseTracking.d.ts +6 -0
  38. package/dist/spaceTimeChart/hooks/useSize.d.ts +8 -0
  39. package/dist/spaceTimeChart/index.d.ts +9 -0
  40. package/dist/spaceTimeChart/lib/consts.d.ts +20 -0
  41. package/dist/spaceTimeChart/lib/context.d.ts +16 -0
  42. package/dist/spaceTimeChart/lib/theme.d.ts +2 -0
  43. package/dist/spaceTimeChart/lib/types.d.ts +209 -0
  44. package/dist/spaceTimeChart/stories/additional-data.stories.d.ts +20 -0
  45. package/dist/spaceTimeChart/stories/base-rendering.stories.d.ts +28 -0
  46. package/dist/spaceTimeChart/stories/custom-styles.stories.d.ts +24 -0
  47. package/dist/spaceTimeChart/stories/horizontal-zoom.stories.d.ts +31 -0
  48. package/dist/spaceTimeChart/stories/layers.stories.d.ts +9 -0
  49. package/dist/spaceTimeChart/stories/lib/components.d.ts +15 -0
  50. package/dist/spaceTimeChart/stories/lib/paths.d.ts +16 -0
  51. package/dist/spaceTimeChart/stories/lib/utils.d.ts +22 -0
  52. package/dist/spaceTimeChart/stories/measuring.stories.d.ts +20 -0
  53. package/dist/spaceTimeChart/stories/options.stories.d.ts +27 -0
  54. package/dist/spaceTimeChart/stories/paths-interactions.stories.d.ts +24 -0
  55. package/dist/spaceTimeChart/stories/performances.stories.d.ts +25 -0
  56. package/dist/spaceTimeChart/stories/rectangle-zoom.stories.d.ts +40 -0
  57. package/dist/spaceTimeChart/stories/scroll-navigation.stories.d.ts +19 -0
  58. package/dist/spaceTimeChart/stories/split.stories.d.ts +21 -0
  59. package/dist/spaceTimeChart/stories/stage-interactions.stories.d.ts +25 -0
  60. package/dist/spaceTimeChart/stories/work-schedules.stories.d.ts +31 -0
  61. package/dist/spaceTimeChart/types.d.ts +6 -0
  62. package/dist/spaceTimeChart/utils/__tests__/canvas.spec.d.ts +1 -0
  63. package/dist/spaceTimeChart/utils/canvas.d.ts +55 -0
  64. package/dist/spaceTimeChart/utils/colors.d.ts +13 -0
  65. package/dist/spaceTimeChart/utils/events.d.ts +12 -0
  66. package/dist/spaceTimeChart/utils/geometry.d.ts +13 -0
  67. package/dist/spaceTimeChart/utils/paths.d.ts +16 -0
  68. package/dist/spaceTimeChart/utils/png.d.ts +5 -0
  69. package/dist/spaceTimeChart/utils/scales.d.ts +45 -0
  70. package/dist/spaceTimeChart/utils/snapping.d.ts +10 -0
  71. package/dist/spaceTimeChart/utils/vectors.d.ts +2 -0
  72. package/dist/speedSpaceChart/__tests__/utils.spec.d.ts +1 -0
  73. package/dist/speedSpaceChart/components/SpeedSpaceChart.d.ts +31 -0
  74. package/dist/speedSpaceChart/components/common/DetailsBox.d.ts +19 -0
  75. package/dist/speedSpaceChart/components/common/InteractionButtons.d.ts +9 -0
  76. package/dist/speedSpaceChart/components/common/SettingsPanel.d.ts +13 -0
  77. package/dist/speedSpaceChart/components/common/Tooltip.d.ts +9 -0
  78. package/dist/speedSpaceChart/components/const.d.ts +53 -0
  79. package/dist/speedSpaceChart/components/helpers/drawElements/axisY.d.ts +2 -0
  80. package/dist/speedSpaceChart/components/helpers/drawElements/curve.d.ts +2 -0
  81. package/dist/speedSpaceChart/components/helpers/drawElements/declivity.d.ts +2 -0
  82. package/dist/speedSpaceChart/components/helpers/drawElements/electricalProfile.d.ts +2 -0
  83. package/dist/speedSpaceChart/components/helpers/drawElements/powerRestrictions.d.ts +2 -0
  84. package/dist/speedSpaceChart/components/helpers/drawElements/reticle.d.ts +13 -0
  85. package/dist/speedSpaceChart/components/helpers/drawElements/speedLimitTags.d.ts +3 -0
  86. package/dist/speedSpaceChart/components/helpers/drawElements/speedLimits.d.ts +2 -0
  87. package/dist/speedSpaceChart/components/helpers/drawElements/steps.d.ts +2 -0
  88. package/dist/speedSpaceChart/components/helpers/drawElements/tickX.d.ts +2 -0
  89. package/dist/speedSpaceChart/components/helpers/drawElements/tickYRight.d.ts +2 -0
  90. package/dist/speedSpaceChart/components/helpers/frontFrame.d.ts +2 -0
  91. package/dist/speedSpaceChart/components/helpers/layersManager.d.ts +4 -0
  92. package/dist/speedSpaceChart/components/hooks.d.ts +11 -0
  93. package/dist/speedSpaceChart/components/layers/CurveLayer.d.ts +9 -0
  94. package/dist/speedSpaceChart/components/layers/DeclivityLayer.d.ts +9 -0
  95. package/dist/speedSpaceChart/components/layers/ElectricalProfileLayer.d.ts +9 -0
  96. package/dist/speedSpaceChart/components/layers/FrontInteractivityLayer.d.ts +10 -0
  97. package/dist/speedSpaceChart/components/layers/PowerRestrictionsLayer.d.ts +9 -0
  98. package/dist/speedSpaceChart/components/layers/ReticleLayer.d.ts +10 -0
  99. package/dist/speedSpaceChart/components/layers/SpeedLimitTagsLayer.d.ts +9 -0
  100. package/dist/speedSpaceChart/components/layers/SpeedLimitsLayer.d.ts +9 -0
  101. package/dist/speedSpaceChart/components/layers/StepsLayer.d.ts +9 -0
  102. package/dist/speedSpaceChart/components/layers/TickLayerX.d.ts +9 -0
  103. package/dist/speedSpaceChart/components/layers/TickLayerY.d.ts +9 -0
  104. package/dist/speedSpaceChart/components/layers/TickLayerYRight.d.ts +9 -0
  105. package/dist/speedSpaceChart/components/layers/index.d.ts +12 -0
  106. package/dist/speedSpaceChart/components/utils.d.ts +115 -0
  107. package/dist/speedSpaceChart/index.d.ts +3 -0
  108. package/dist/speedSpaceChart/stories/SpeedSpaceChart.stories.d.ts +8 -0
  109. package/dist/speedSpaceChart/stories/assets/const.d.ts +70 -0
  110. package/dist/speedSpaceChart/stories/assets/path_properties_PMP_LM.d.ts +2 -0
  111. package/dist/speedSpaceChart/stories/assets/power_restrictions_PMP_LM.d.ts +7 -0
  112. package/dist/speedSpaceChart/stories/assets/simulation_PMP_LM.d.ts +2 -0
  113. package/dist/speedSpaceChart/stories/assets/speed_limit_tags_PMP_LM.d.ts +9 -0
  114. package/dist/speedSpaceChart/stories/utils.d.ts +5 -0
  115. package/dist/speedSpaceChart/types/chartTypes.d.ts +114 -0
  116. package/dist/speedSpaceChart/types/simulationTypes.d.ts +47 -0
  117. package/dist/theme.css +6490 -0
  118. package/dist/theme.css.map +1 -0
  119. package/dist/trackOccupancyDiagram/__tests__/utils.spec.d.ts +1 -0
  120. package/dist/trackOccupancyDiagram/components/TrackOccupancyCanvas.d.ts +4 -0
  121. package/dist/trackOccupancyDiagram/components/TrackOccupancyManchette.d.ts +4 -0
  122. package/dist/trackOccupancyDiagram/components/consts.d.ts +30 -0
  123. package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawOccupancyZones.d.ts +15 -0
  124. package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawOccupancyZonesTexts.d.ts +10 -0
  125. package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawTrack.d.ts +11 -0
  126. package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawTracks.d.ts +16 -0
  127. package/dist/trackOccupancyDiagram/components/layers/OccupancyZonesLayer.d.ts +11 -0
  128. package/dist/trackOccupancyDiagram/components/layers/TracksLayer.d.ts +5 -0
  129. package/dist/trackOccupancyDiagram/components/types.d.ts +33 -0
  130. package/dist/trackOccupancyDiagram/components/utils.d.ts +24 -0
  131. package/dist/trackOccupancyDiagram/index.d.ts +3 -0
  132. package/package.json +60 -0
@@ -0,0 +1,115 @@
1
+ import { MARGINS, type LAYERS_SELECTION } from './const';
2
+ import type { LayerData, OperationalPoints, Store } from '../types/chartTypes';
3
+ type SlopesValues = {
4
+ minGradient: number;
5
+ maxGradient: number;
6
+ slopesRange: number;
7
+ maxPosition: number;
8
+ };
9
+ export type VisibilityFilterOptions<T> = {
10
+ elements: T[];
11
+ getPosition: (element: T) => number;
12
+ getWeight: (element: T) => number | undefined;
13
+ minSpace: number;
14
+ };
15
+ export declare const getGraphOffsets: (width: number, height: number, declivities?: boolean) => {
16
+ WIDTH_OFFSET: number;
17
+ HEIGHT_OFFSET: number;
18
+ };
19
+ /**
20
+ * Given the store, return the max speed value.
21
+ * Can be either the max speed value from the MRSP or the max speed value from the speeds,
22
+ * depending on the layers displayed.
23
+ * @param store
24
+ */
25
+ export declare const maxSpeedValue: (store: Store) => number;
26
+ /**
27
+ * Given a list of speed data return the max position
28
+ * @param speeds
29
+ */
30
+ export declare const maxPositionValue: (speeds: LayerData<number>[]) => number;
31
+ export declare const clearCanvas: (ctx: CanvasRenderingContext2D, width: number, height: number) => void;
32
+ /**
33
+ * Calculates the adaptive height based on the height supplied and the lineaires displayed.
34
+ * @param height - The initial height value.
35
+ * @param layersDisplay - The linear display options.
36
+ * @param isIncludingLinearLayers - A flag to add or remove layers. Default is true.
37
+ * @returns The calculated adaptive height.
38
+ */
39
+ export declare const getAdaptiveHeight: (height: number, layersDisplay: Store["layersDisplay"], isIncludingLinearLayers?: boolean) => number;
40
+ /**
41
+ * Calculates the top position for the linear layers based on the height and the layers displayed.
42
+ * The speed limit tags linear layer needs to call this function with the isSpeedLimitByTag flag set to true.
43
+ */
44
+ export declare const getLinearLayerMarginTop: (height: number, layersDisplay: Store["layersDisplay"], isSpeedLimitByTag?: boolean) => number;
45
+ export declare const getLinearLayersDisplayedHeight: (layersDisplay: Store["layersDisplay"]) => number;
46
+ /**
47
+ * Calculates the position on the graph scale based on the given parameters.
48
+ * @param position - The current position.
49
+ * @param maxPosition - The maximum position.
50
+ * @param width - The width of the graph.
51
+ * @param ratioX - The X-axis ratio.
52
+ * @param margins - The margins of the graph.
53
+ * @returns The calculated position on the graph scale.
54
+ */
55
+ export declare const positionOnGraphScale: (position: number, maxPosition: number, width: number, ratioX: number, margins: typeof MARGINS) => number;
56
+ /**
57
+ * Draws a separator line on a canvas context.
58
+ *
59
+ * @param ctx - The canvas rendering context.
60
+ * @param separatorColor - The color of the separator line.
61
+ * @param margins - The margins of the canvas.
62
+ * @param width - The width of the canvas.
63
+ * @param height - The height of the canvas.
64
+ */
65
+ export declare const drawSeparatorLinearLayer: (ctx: CanvasRenderingContext2D, separatorColor: string, margins: typeof MARGINS, width: number, height: number) => void;
66
+ /**
67
+ * Draw the background for linear layers. Depending on the layer and how many are displayed, the background color
68
+ * will change.
69
+ * @param backgroundColor depends on the linear layer. Electrical profile is always first, power restrictions
70
+ * can be first or second, speedlimit tags can be on any position.
71
+ */
72
+ export declare const drawLinearLayerBackground: (ctx: CanvasRenderingContext2D, backgroundColor: string, margins: typeof MARGINS, width: number, startingHeight: number, layerHeight: number) => void;
73
+ /**
74
+ * Return wether a layer should be active or not.
75
+ * Depending on the available data, some layers should be disabled.
76
+ */
77
+ export declare const isLayerActive: (store: Store, selection: (typeof LAYERS_SELECTION)[number]) => true | import("../types/chartTypes").ValuesAlongPath<import("../types/chartTypes").SpeedLimit> | LayerData<import("../types/chartTypes").ElectricalPofilelValues>[] | LayerData<import("../types/chartTypes").PowerRestrictionValues>[] | LayerData<import("../types/chartTypes").SpeedLimitTagValues>[] | undefined;
78
+ /**
79
+ * Given a store including a list of slopes, return the position and value of min and max slopes
80
+ * @param store
81
+ */
82
+ export declare const slopesValues: (store: Store) => SlopesValues;
83
+ export declare const drawSvgImageWithColor: (ctx: CanvasRenderingContext2D, image: HTMLImageElement, x: number, y: number, width: number, height: number, color: string) => void;
84
+ export declare const drawRoundedRect: (ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, radius: number) => void;
85
+ export declare const loadSvgImage: (svgUrl: string) => Promise<HTMLImageElement>;
86
+ export declare const createSvgBlobUrl: (svgString: string) => string;
87
+ /** Retrieve the index of an element in the list.
88
+ * If the element is not found, return the predecessor.
89
+ * If the element is smaller than the first element, return 0.
90
+ * If the element is greater than the last element, return the last index.
91
+ * If the list is empty, return -1.
92
+ * @param data - The **sorted** data array.
93
+ * @param element - The element to search
94
+ * @param lambda - The function to extract the value from the data list.
95
+ */
96
+ export declare const binarySearch: <T>(data: T[], element: number, lambda: (element: T) => number) => number;
97
+ /** Convert meters to kilometers */
98
+ export declare const convertMToKm: (meters: number) => number;
99
+ /** Transform a position in km into a position on the x-axis in pixels */
100
+ export declare const positionToPosX: (position: number, maxPosition: number, width: number, ratioX: number, leftOffset?: number) => number;
101
+ /** Interpole on a straight line given two points and the x-axis value */
102
+ export declare const interpolate: (x1: number, y1: number, x2: number, y2: number, x: number) => number;
103
+ /** Clamps the given value between the given minimum number and maximum number values */
104
+ export declare const clamp: (value: number, min: number, max: number) => number;
105
+ export declare const filterVisibleElements: <T>({ elements, getPosition, getWeight, minSpace, }: VisibilityFilterOptions<T>) => T[];
106
+ /** Filter stops to avoid overlapping, showing the most important stops first */
107
+ export declare const getDisplayedStops: (stops: LayerData<OperationalPoints>[], ratioX: number, width: number, maxPosition: number, minSpace?: number) => LayerData<OperationalPoints>[];
108
+ /** Compute the cursor position on the x-axis given its position on the canva */
109
+ export declare const getCursorPosition: (cursorX: number, width: number, store: Store) => number;
110
+ /**
111
+ * Retrieve the snapped stop given the cursor position.
112
+ * If the cursor is not close enough to a stop, return null.
113
+ */
114
+ export declare const getSnappedStop: (cursorX: number, width: number, store: Store) => LayerData<OperationalPoints> | null;
115
+ export {};
@@ -0,0 +1,3 @@
1
+ import '@osrd-project/ui-core/dist/theme.css';
2
+ import './styles/main.css';
3
+ export { default as SpeedSpaceChart } from './components/SpeedSpaceChart';
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import '@osrd-project/ui-core/dist/theme.css';
3
+ import '@osrd-project/ui-charts/dist/theme.css';
4
+ import SpeedSpaceChart from '../components/SpeedSpaceChart';
5
+ declare const meta: Meta<typeof SpeedSpaceChart>;
6
+ export default meta;
7
+ type Story = StoryObj<typeof SpeedSpaceChart>;
8
+ export declare const SpeedSpaceChartDefault: Story;
@@ -0,0 +1,70 @@
1
+ export declare const translations: {
2
+ detailsBoxDisplay: {
3
+ reticleInfos: string;
4
+ energySource: string;
5
+ tractionStatus: string;
6
+ declivities: string;
7
+ electricalProfiles: string;
8
+ powerRestrictions: string;
9
+ };
10
+ layersDisplay: {
11
+ context: string;
12
+ steps: string;
13
+ declivities: string;
14
+ speedLimits: string;
15
+ temporarySpeedLimits: string;
16
+ electricalProfiles: string;
17
+ powerRestrictions: string;
18
+ speedLimitTags: string;
19
+ };
20
+ };
21
+ export declare const electricalProfilesDesignValues: {
22
+ BB01: {
23
+ color: string;
24
+ heightLevel: number;
25
+ };
26
+ BB02: {
27
+ color: string;
28
+ heightLevel: number;
29
+ };
30
+ BB03: {
31
+ color: string;
32
+ heightLevel: number;
33
+ };
34
+ AA01: {
35
+ color: string;
36
+ heightLevel: number;
37
+ };
38
+ AA02: {
39
+ color: string;
40
+ heightLevel: number;
41
+ };
42
+ AA03: {
43
+ color: string;
44
+ heightLevel: number;
45
+ };
46
+ AA04: {
47
+ color: string;
48
+ heightLevel: number;
49
+ };
50
+ AA05: {
51
+ color: string;
52
+ heightLevel: number;
53
+ };
54
+ AA06: {
55
+ color: string;
56
+ heightLevel: number;
57
+ };
58
+ AA07: {
59
+ color: string;
60
+ heightLevel: number;
61
+ };
62
+ AA08: {
63
+ color: string;
64
+ heightLevel: number;
65
+ };
66
+ AA09: {
67
+ color: string;
68
+ heightLevel: number;
69
+ };
70
+ };
@@ -0,0 +1,2 @@
1
+ import type { PathProperties } from '../../types/simulationTypes';
2
+ export declare const pathPropertiesPmpLm: PathProperties;
@@ -0,0 +1,7 @@
1
+ export type PowerRestriction = {
2
+ code: string;
3
+ handled: boolean;
4
+ start: number;
5
+ stop: number;
6
+ };
7
+ export declare const powerRestrictionsPmpLm: PowerRestriction[];
@@ -0,0 +1,2 @@
1
+ import type { Simulation } from '../../types/simulationTypes';
2
+ export declare const simulationPmpLm: Simulation;
@@ -0,0 +1,9 @@
1
+ export type SpeedLimitTags = {
2
+ boundaries: number[];
3
+ values: {
4
+ speed_limit_tags_type: string;
5
+ tag_name: string;
6
+ color: string;
7
+ }[];
8
+ };
9
+ export declare const speedLimitTags: SpeedLimitTags;
@@ -0,0 +1,5 @@
1
+ import type { PowerRestriction } from './assets/power_restrictions_PMP_LM';
2
+ import type { SpeedLimitTags } from './assets/speed_limit_tags_PMP_LM';
3
+ import type { Data } from '../types/chartTypes';
4
+ import type { PathProperties, Simulation } from '../types/simulationTypes';
5
+ export declare const formatData: (simulation: Simulation, pathProperties: PathProperties, powerRestrictionsData: PowerRestriction[], speedLimitTagsData: SpeedLimitTags) => Data;
@@ -0,0 +1,114 @@
1
+ export type ElectricalPofilelValues = {
2
+ electricalProfile: string;
3
+ color?: string;
4
+ heightLevel?: number;
5
+ handled?: boolean;
6
+ };
7
+ export type PowerRestrictionValues = {
8
+ powerRestriction: string;
9
+ handled: boolean;
10
+ };
11
+ export type SpeedLimitTagValues = {
12
+ tag: string;
13
+ color: string;
14
+ };
15
+ export type ElectrificationValues = {
16
+ type: 'electrification' | 'neutral_section' | 'non_electrified';
17
+ voltage?: '1500V' | '25000V';
18
+ lowerPantograph?: boolean;
19
+ };
20
+ export type LayerData<T> = {
21
+ position: {
22
+ start: number;
23
+ end?: number;
24
+ };
25
+ value: T;
26
+ };
27
+ export type OperationalPoints = {
28
+ name: string;
29
+ weight?: number;
30
+ };
31
+ export type ValuesAlongPath<T> = {
32
+ boundaries: number[];
33
+ values: T[];
34
+ };
35
+ export type SpeedLimit = {
36
+ speed: number;
37
+ isTemporary: boolean;
38
+ };
39
+ export type Data = {
40
+ speeds: LayerData<number>[];
41
+ ecoSpeeds: LayerData<number>[];
42
+ stops: LayerData<OperationalPoints>[];
43
+ electrifications: LayerData<ElectrificationValues>[];
44
+ slopes: LayerData<number>[];
45
+ mrsp?: ValuesAlongPath<SpeedLimit>;
46
+ electricalProfiles?: LayerData<ElectricalPofilelValues>[];
47
+ powerRestrictions?: LayerData<PowerRestrictionValues>[];
48
+ speedLimitTags?: LayerData<SpeedLimitTagValues>[];
49
+ trainLength: number;
50
+ };
51
+ export type Store = Data & {
52
+ ratioX: number;
53
+ leftOffset: number;
54
+ cursor: {
55
+ x: number | null;
56
+ y: number | null;
57
+ };
58
+ detailsBoxDisplay: {
59
+ energySource: boolean;
60
+ tractionStatus: boolean;
61
+ declivities: boolean;
62
+ electricalProfiles: boolean;
63
+ powerRestrictions: boolean;
64
+ };
65
+ layersDisplay: {
66
+ steps: boolean;
67
+ declivities: boolean;
68
+ speedLimits: boolean;
69
+ electricalProfiles: boolean;
70
+ powerRestrictions: boolean;
71
+ speedLimitTags: boolean;
72
+ };
73
+ isSettingsPanelOpened: boolean;
74
+ };
75
+ export type DrawFunctionParams = {
76
+ ctx: CanvasRenderingContext2D;
77
+ width: number;
78
+ height: number;
79
+ store: Store;
80
+ setStore?: React.Dispatch<React.SetStateAction<Store>>;
81
+ };
82
+ export type SpeedLimitTagsLayerDrawingStore = Pick<Store, 'speedLimitTags' | 'ratioX' | 'leftOffset' | 'speeds'> & {
83
+ layersDisplay: Pick<Store['layersDisplay'], 'electricalProfiles' | 'powerRestrictions'>;
84
+ };
85
+ export type SpeedLimitTagsLayerDrawFunctionParams = {
86
+ ctx: CanvasRenderingContext2D;
87
+ width: number;
88
+ height: number;
89
+ store: SpeedLimitTagsLayerDrawingStore;
90
+ images: {
91
+ questionImage: HTMLImageElement | null;
92
+ alertFillImage: HTMLImageElement | null;
93
+ };
94
+ };
95
+ export type TrainDetails = {
96
+ curveX: number;
97
+ curveY: number;
98
+ speedText: string;
99
+ ecoSpeedText: string;
100
+ effortText: string;
101
+ electricalModeText: string;
102
+ electricalProfileText: string;
103
+ powerRestrictionText: string;
104
+ previousGradientText: number;
105
+ modeText: string;
106
+ };
107
+ export type tooltipInfos = {
108
+ cursorX: number;
109
+ cursorY: number;
110
+ text: string;
111
+ };
112
+ export type ColorDictionary = {
113
+ [key: string]: string;
114
+ };
@@ -0,0 +1,47 @@
1
+ import { type electricalProfilesDesignValues } from '../stories/assets/const';
2
+ export type Simulation = {
3
+ base: {
4
+ positions: number[];
5
+ speeds: number[];
6
+ };
7
+ final_output: {
8
+ positions: number[];
9
+ speeds: number[];
10
+ };
11
+ electrical_profiles: {
12
+ boundaries: number[];
13
+ values: {
14
+ electrical_profile_type: 'profile' | 'no_profile';
15
+ profile?: keyof typeof electricalProfilesDesignValues | null;
16
+ handled?: boolean;
17
+ }[];
18
+ };
19
+ mrsp: {
20
+ boundaries: number[];
21
+ values: number[];
22
+ };
23
+ };
24
+ export type PathProperties = {
25
+ slopes: {
26
+ boundaries: number[];
27
+ values: number[];
28
+ };
29
+ electrifications: {
30
+ boundaries: number[];
31
+ values: {
32
+ type: 'electrification' | 'neutral_section';
33
+ voltage?: '1500V' | '25000V';
34
+ lower_pantograph?: boolean;
35
+ }[];
36
+ };
37
+ operational_points: {
38
+ extensions: {
39
+ ch: string;
40
+ identifier: {
41
+ name: string;
42
+ };
43
+ weight?: number;
44
+ };
45
+ position: number;
46
+ }[];
47
+ };