mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
refactoring of code for easier access and avoid hanging issues
CURA-7647
This commit is contained in:
parent
a19c667106
commit
189a22aa4f
2 changed files with 11 additions and 9 deletions
|
@ -402,10 +402,13 @@ class SimulationView(CuraView):
|
|||
def getMaxFeedrate(self) -> float:
|
||||
return self._max_feedrate
|
||||
|
||||
def getSimulationTime(self) -> list:
|
||||
if len(self._lengths_of_polyline) > 0 and len(self._lengths_of_polyline) == len(self._current_feedrates):
|
||||
return self._lengths_of_polyline[self._current_layer_num] / self._current_feedrates[self._current_layer_num]
|
||||
return numpy.zeros(0)
|
||||
def getSimulationTime(self, currentIndex) -> list:
|
||||
try:
|
||||
return self._lengths_of_polyline[self._current_layer_num][currentIndex] / self._current_feedrates[self._current_layer_num][currentIndex]
|
||||
except:
|
||||
# In case of change in layers, currentIndex comes one more than the items in the lengths_of_polyline
|
||||
# We give 1 second time for layer change
|
||||
return 1
|
||||
|
||||
def getMinThickness(self) -> float:
|
||||
if abs(self._min_thickness - sys.float_info.max) < 10: # Some lenience due to floating point rounding.
|
||||
|
@ -535,6 +538,8 @@ class SimulationView(CuraView):
|
|||
visible_feedrates = numpy.take(polyline.lineFeedrates, visible_indices)
|
||||
visible_feedrates_with_extrusion = numpy.take(polyline.lineFeedrates, visible_indicies_with_extrusion)
|
||||
self._current_feedrates[layer_index] = polyline.lineFeedrates
|
||||
# if len(polyline.lineLengths) > 0 and len(polyline.lineLengths) == len(polyline.lineFeedrates):
|
||||
# self._simulation_time[layer_index] = polyline.lineLengths / polyline.lineFeedrates
|
||||
visible_linewidths = numpy.take(polyline.lineWidths, visible_indices)
|
||||
visible_linewidths_with_extrusion = numpy.take(polyline.lineWidths, visible_indicies_with_extrusion)
|
||||
visible_thicknesses = numpy.take(polyline.lineThicknesses, visible_indices)
|
||||
|
|
|
@ -57,12 +57,9 @@ class SimulationViewProxy(QObject):
|
|||
|
||||
@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.
|
||||
# Extracts the currents paths simulation time (in seconds) for the current path 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
|
||||
simulationTimeOfpath = self._simulation_view.getSimulationTime(self._simulation_view.getCurrentPath()) * 100
|
||||
# Since the timer cannot process time less than 1 ms, we put a lower limit here
|
||||
return int(max(1, simulationTimeOfpath))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue