mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-07-06 02:25:10 +08:00
Merge pull request #19895 from Ultimaker/CURA-12192_replay-preview-at-last-layer
CURA-12192 Loop back to the beginning when ending simulation playback
This commit is contained in:
commit
07bb38e76a
@ -222,12 +222,11 @@ class SimulationView(CuraView):
|
|||||||
|
|
||||||
self.setPath(i + fractional_value)
|
self.setPath(i + fractional_value)
|
||||||
|
|
||||||
def advanceTime(self, time_increase: float) -> bool:
|
def advanceTime(self, time_increase: float) -> None:
|
||||||
"""
|
"""
|
||||||
Advance the time by the given amount.
|
Advance the time by the given amount.
|
||||||
|
|
||||||
:param time_increase: The amount of time to advance (in seconds).
|
:param time_increase: The amount of time to advance (in seconds).
|
||||||
:return: True if the time was advanced, False if the end of the simulation was reached.
|
|
||||||
"""
|
"""
|
||||||
total_duration = 0.0
|
total_duration = 0.0
|
||||||
if len(self.cumulativeLineDuration()) > 0:
|
if len(self.cumulativeLineDuration()) > 0:
|
||||||
@ -237,15 +236,13 @@ class SimulationView(CuraView):
|
|||||||
# If we have reached the end of the simulation, go to the next layer.
|
# If we have reached the end of the simulation, go to the next layer.
|
||||||
if self.getCurrentLayer() == self.getMaxLayers():
|
if self.getCurrentLayer() == self.getMaxLayers():
|
||||||
# If we are already at the last layer, go to the first layer.
|
# If we are already at the last layer, go to the first layer.
|
||||||
self.setTime(total_duration)
|
self.setLayer(0)
|
||||||
return False
|
else:
|
||||||
|
# advance to the next layer, and reset the time
|
||||||
# advance to the next layer, and reset the time
|
self.setLayer(self.getCurrentLayer() + 1)
|
||||||
self.setLayer(self.getCurrentLayer() + 1)
|
|
||||||
self.setTime(0.0)
|
self.setTime(0.0)
|
||||||
else:
|
else:
|
||||||
self.setTime(self._current_time + time_increase)
|
self.setTime(self._current_time + time_increase)
|
||||||
return True
|
|
||||||
|
|
||||||
def cumulativeLineDuration(self) -> List[float]:
|
def cumulativeLineDuration(self) -> List[float]:
|
||||||
# Make sure _cumulative_line_duration is initialized properly
|
# Make sure _cumulative_line_duration is initialized properly
|
||||||
|
@ -144,9 +144,7 @@ Item
|
|||||||
{
|
{
|
||||||
// divide by 1000 to account for ms to s conversion
|
// divide by 1000 to account for ms to s conversion
|
||||||
const advance_time = simulationTimer.interval / 1000.0;
|
const advance_time = simulationTimer.interval / 1000.0;
|
||||||
if (!UM.SimulationView.advanceTime(advance_time)) {
|
UM.SimulationView.advanceTime(advance_time);
|
||||||
playButton.pauseSimulation();
|
|
||||||
}
|
|
||||||
// The status must be set here instead of in the resumeSimulation function otherwise it won't work
|
// The status must be set here instead of in the resumeSimulation function otherwise it won't work
|
||||||
// correctly, because part of the logic is in this trigger function.
|
// correctly, because part of the logic is in this trigger function.
|
||||||
isSimulationPlaying = true;
|
isSimulationPlaying = true;
|
||||||
|
@ -54,9 +54,9 @@ class SimulationViewProxy(QObject):
|
|||||||
def currentPath(self):
|
def currentPath(self):
|
||||||
return self._simulation_view.getCurrentPath()
|
return self._simulation_view.getCurrentPath()
|
||||||
|
|
||||||
@pyqtSlot(float, result=bool)
|
@pyqtSlot(float)
|
||||||
def advanceTime(self, duration: float) -> bool:
|
def advanceTime(self, duration: float) -> None:
|
||||||
return self._simulation_view.advanceTime(duration)
|
self._simulation_view.advanceTime(duration)
|
||||||
|
|
||||||
@pyqtProperty(int, notify=currentPathChanged)
|
@pyqtProperty(int, notify=currentPathChanged)
|
||||||
def minimumPath(self):
|
def minimumPath(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user