1
1
import { useMemo , useRef , useState } from 'react' ;
2
2
3
- import { KebabHorizontal } from '@osrd-project/ui-icons' ;
3
+ import { Slider } from '@osrd-project/ui-core' ;
4
+ import { KebabHorizontal , Iterations } from '@osrd-project/ui-icons' ;
4
5
import Manchette , { type WaypointMenuData } from '@osrd-project/ui-manchette' ;
5
- import { useManchettesWithSpaceTimeChart } from '@osrd-project/ui-manchette-with-spacetimechart' ;
6
+ import {
7
+ useManchettesWithSpaceTimeChart ,
8
+ timeScaleToZoomValue ,
9
+ DEFAULT_ZOOM_MS_PER_PX ,
10
+ } from '@osrd-project/ui-manchette-with-spacetimechart' ;
6
11
import {
7
12
ConflictLayer ,
8
13
PathLayer ,
@@ -50,6 +55,7 @@ type ManchetteWithSpaceTimeChartProps = {
50
55
export const MANCHETTE_WITH_SPACE_TIME_CHART_DEFAULT_HEIGHT = 561 ;
51
56
const BOTTOM_TOOLBAR_HEIGHT = 40 ;
52
57
const SPACE_TIME_CHART_DIFF_HEIGHT = 8 ;
58
+ const DEFAULT_ZOOM_MS_PER_PX = 7500 ;
53
59
54
60
const ManchetteWithSpaceTimeChartWrapper = ( {
55
61
operationalPoints,
@@ -63,6 +69,7 @@ const ManchetteWithSpaceTimeChartWrapper = ({
63
69
} : ManchetteWithSpaceTimeChartProps ) => {
64
70
const manchetteWithSpaceTimeCharWrappertRef = useRef < HTMLDivElement > ( null ) ;
65
71
const manchetteWithSpaceTimeChartRef = useRef < HTMLDivElement > ( null ) ;
72
+ const spaceTimeChartRef = useRef < HTMLDivElement > ( null ) ;
66
73
67
74
const [ waypointsPanelIsOpen , setWaypointsPanelIsOpen ] = useState ( false ) ;
68
75
@@ -159,13 +166,15 @@ const ManchetteWithSpaceTimeChartWrapper = ({
159
166
} ) ) ;
160
167
} , [ waypointsPanelData , operationalPoints ] ) ;
161
168
162
- const { manchetteProps, spaceTimeChartProps, handleScroll } = useManchettesWithSpaceTimeChart (
163
- manchetteWaypoints ,
164
- cutProjectedTrains ,
165
- manchetteWithSpaceTimeChartRef ,
166
- selectedTrainScheduleId ,
167
- height
168
- ) ;
169
+ const { manchetteProps, spaceTimeChartProps, handleScroll, handleXZoom, xZoom } =
170
+ useManchettesWithSpaceTimeChart (
171
+ manchetteWaypoints ,
172
+ cutProjectedTrains ,
173
+ manchetteWithSpaceTimeChartRef ,
174
+ selectedTrainScheduleId ,
175
+ height ,
176
+ spaceTimeChartRef
177
+ ) ;
169
178
170
179
const [ showSettingsPanel , setShowSettingsPanel ] = useState ( false ) ;
171
180
const [ settings , setSettings ] = useState ( {
@@ -251,6 +260,7 @@ const ManchetteWithSpaceTimeChartWrapper = ({
251
260
>
252
261
< Manchette { ...manchettePropsWithWaypointMenu } height = { height - BOTTOM_TOOLBAR_HEIGHT } />
253
262
< div
263
+ ref = { spaceTimeChartRef }
254
264
className = "space-time-chart-container"
255
265
style = { {
256
266
bottom : 0 ,
@@ -260,6 +270,12 @@ const ManchetteWithSpaceTimeChartWrapper = ({
260
270
} }
261
271
>
262
272
< div className = "toolbar" >
273
+ < button
274
+ type = "button"
275
+ onClick = { ( ) => handleXZoom ( timeScaleToZoomValue ( DEFAULT_ZOOM_MS_PER_PX ) ) }
276
+ >
277
+ < Iterations />
278
+ </ button >
263
279
< button type = "button" onClick = { ( ) => setShowSettingsPanel ( true ) } >
264
280
< KebabHorizontal />
265
281
</ button >
@@ -301,7 +317,16 @@ const ManchetteWithSpaceTimeChartWrapper = ({
301
317
</ SpaceTimeChart >
302
318
</ div >
303
319
</ div >
320
+ < Slider
321
+ containerClassName = "space-time-h-slider-container"
322
+ className = "space-time-h-slider"
323
+ value = { xZoom }
324
+ onChange = { ( e ) => {
325
+ handleXZoom ( Number ( e . target . value ) ) ;
326
+ } }
327
+ />
304
328
</ div >
329
+ /* TODO use margin or absolute to align with handle */
305
330
) ;
306
331
} ;
307
332
0 commit comments