Commit 1aa4eb66 authored by Loïck Bonniot's avatar Loïck Bonniot
Browse files

[d] Add step-by-step and remove auto replay

parent 075c808d
Pipeline #1812 passed with stage
...@@ -91,6 +91,7 @@ func (w *Window) initTimer() { ...@@ -91,6 +91,7 @@ func (w *Window) initTimer() {
w.timer.OnTimeout(func() { w.timer.OnTimeout(func() {
nbEvents := len(w.scene.Events) nbEvents := len(w.scene.Events)
if w.scene.currentEvent >= nbEvents { if w.scene.currentEvent >= nbEvents {
w.stopButton.Click()
w.replayButton.Click() w.replayButton.Click()
return return
} }
...@@ -116,6 +117,7 @@ func (w *Window) initTimer() { ...@@ -116,6 +117,7 @@ func (w *Window) initTimer() {
quantum := time.Duration(w.quantumField.Value()) * time.Microsecond quantum := time.Duration(w.quantumField.Value()) * time.Microsecond
endOfQuantum := w.scene.currentTime.Add(quantum) endOfQuantum := w.scene.currentTime.Add(quantum)
drawnEvents := 0
for i := w.scene.currentEvent; i < nbEvents; i++ { for i := w.scene.currentEvent; i < nbEvents; i++ {
e := w.scene.Events[i] e := w.scene.Events[i]
...@@ -125,10 +127,15 @@ func (w *Window) initTimer() { ...@@ -125,10 +127,15 @@ func (w *Window) initTimer() {
w.DrawEvent(&e) w.DrawEvent(&e)
w.scene.currentEvent++ w.scene.currentEvent++
drawnEvents++
} }
w.PrintQuantumInformation() w.PrintQuantumInformation()
w.scene.currentTime = endOfQuantum w.scene.currentTime = endOfQuantum
if w.speedSlider.Value() == 0 && drawnEvents > 0 {
w.stopButton.Click() // step-by-step
}
}) })
} }
......
...@@ -187,7 +187,7 @@ ...@@ -187,7 +187,7 @@
<enum>Qt::TabFocus</enum> <enum>Qt::TabFocus</enum>
</property> </property>
<property name="minimum"> <property name="minimum">
<number>1</number> <number>0</number>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>20</number> <number>20</number>
......
...@@ -122,7 +122,11 @@ func (w *Window) addActions() { ...@@ -122,7 +122,11 @@ func (w *Window) addActions() {
w.playButton.OnClicked(func() { w.playButton.OnClicked(func() {
w.playButton.SetDisabled(true) w.playButton.SetDisabled(true)
w.stopButton.SetDisabled(false) w.stopButton.SetDisabled(false)
speed := 2000 / w.speedSlider.Value() s := w.speedSlider.Value()
if s == 0 {
s = 100 // step-by-step arbitrary speed value
}
speed := 2000 / s
w.timer.StartWithMsec(speed) w.timer.StartWithMsec(speed)
}) })
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment