Simulation time fed to the timer controlling speed

simulation time is made 10x faster than the actual time, for better visualisation

CURA-7647
This commit is contained in:
saumya.jain 2023-12-08 11:41:16 +01:00
parent 88d7d65622
commit bf2c8b5a08
3 changed files with 22 additions and 9 deletions

View file

@ -2,9 +2,11 @@
# Cura is released under the terms of the LGPLv3 or higher.
from typing import TYPE_CHECKING
import numpy
from PyQt6.QtCore import QObject, pyqtSignal, pyqtProperty
from UM.FlameProfiler import pyqtSlot
from UM.Application import Application
from UM.Logger import Logger
if TYPE_CHECKING:
from .SimulationView import SimulationView
@ -54,6 +56,19 @@ class SimulationViewProxy(QObject):
def currentPath(self):
return self._simulation_view.getCurrentPath()
@pyqtProperty(int, notify=currentPathChanged)
def simulationTime(self):
# This if is activated when there is a layer change
if numpy.all(self._simulation_view.getSimulationTime()==0) or len(self._simulation_view.getSimulationTime()) <= self._simulation_view.getCurrentPath():
return 100
# Extracts the currents paths simulation time (in seconds) from the dict of simulation time of the current layer.
# We multiply the time with 100 to make it to ms from s.(Should be 1000 in real time). This scaling makes the simulation time 10x faster than the real time.
simulationTimeOfpath =self._simulation_view.getSimulationTime()[0][self._simulation_view.getCurrentPath()] * 100
# Since the timer cannot process time less than 1 ms, we put a lower limit here
if simulationTimeOfpath < 1:
return 1
return int(simulationTimeOfpath)
@pyqtProperty(int, notify=currentPathChanged)
def minimumPath(self):
return self._simulation_view.getMinimumPath()