CURA-4526 Change simulation behavior when clicking on Play button

This commit is contained in:
Diego Prado Gesto 2017-11-20 11:24:25 +01:00
parent 41d0df5b5b
commit 56db10d9cb

View file

@ -583,7 +583,6 @@ Item
UM.SimulationView.setSimulationRunning(true) UM.SimulationView.setSimulationRunning(true)
iconSource = "./resources/simulation_pause.svg" iconSource = "./resources/simulation_pause.svg"
simulationTimer.start() simulationTimer.start()
status = 1
} }
} }
} }
@ -599,19 +598,43 @@ Item
var numPaths = UM.SimulationView.numPaths var numPaths = UM.SimulationView.numPaths
var currentLayer = UM.SimulationView.currentLayer var currentLayer = UM.SimulationView.currentLayer
var numLayers = UM.SimulationView.numLayers var numLayers = UM.SimulationView.numLayers
if (currentPath >= numPaths) { // When the user plays the simulation, if the path slider is at the end of this layer, we start
if (currentLayer >= numLayers) { // the simulation at the beginning of the current layer.
if (playButton.status == 0)
{
if (currentPath >= numPaths)
{
UM.SimulationView.setCurrentPath(0)
}
else
{
UM.SimulationView.setCurrentPath(currentPath+1)
}
}
// If the simulation is already playing and we reach the end of a layer, then it automatically
// starts at the beginning of the next layer.
else
{
if (currentPath >= numPaths)
{
// At the end of the model, the simulation stops
if (currentLayer >= numLayers)
{
playButton.pauseSimulation() playButton.pauseSimulation()
} }
else { else
{
UM.SimulationView.setCurrentLayer(currentLayer+1) UM.SimulationView.setCurrentLayer(currentLayer+1)
UM.SimulationView.setCurrentPath(0) UM.SimulationView.setCurrentPath(0)
} }
} }
else { else
{
UM.SimulationView.setCurrentPath(currentPath+1) UM.SimulationView.setCurrentPath(currentPath+1)
} }
} }
playButton.status = 1
}
} }
} }