CURA-5090 empty layer data when new sliced data is empty and prevent some layer data to be processed if it is outdated

This commit is contained in:
Jack Ha 2018-03-19 14:02:02 +01:00
parent 906ebe12e1
commit 10ba900449

View file

@ -224,7 +224,11 @@ class CuraEngineBackend(QObject, Backend):
active_build_plate = Application.getInstance().getMultiBuildPlateModel().activeBuildPlate
build_plate_to_be_sliced = self._build_plates_to_be_sliced.pop(0)
Logger.log("d", "Going to slice build plate [%s]!" % build_plate_to_be_sliced)
num_objects = self._numObjects()
num_objects = self._numObjectsPerBuildPlate()
self._stored_layer_data = []
self._stored_optimized_layer_data[build_plate_to_be_sliced] = []
if build_plate_to_be_sliced not in num_objects or num_objects[build_plate_to_be_sliced] == 0:
self._scene.gcode_dict[build_plate_to_be_sliced] = []
Logger.log("d", "Build plate %s has no objects to be sliced, skipping", build_plate_to_be_sliced)
@ -232,9 +236,6 @@ class CuraEngineBackend(QObject, Backend):
self.slice()
return
self._stored_layer_data = []
self._stored_optimized_layer_data[build_plate_to_be_sliced] = []
if Application.getInstance().getPrintInformation() and build_plate_to_be_sliced == active_build_plate:
Application.getInstance().getPrintInformation().setToZeroPrintInformation(build_plate_to_be_sliced)
@ -426,7 +427,7 @@ class CuraEngineBackend(QObject, Backend):
return False
## Return a dict with number of objects per build plate
def _numObjects(self):
def _numObjectsPerBuildPlate(self):
num_objects = defaultdict(int)
for node in DepthFirstIterator(self._scene.getRoot()):
# Only count sliceable objects
@ -453,7 +454,7 @@ class CuraEngineBackend(QObject, Backend):
source_build_plate_number = source.callDecoration("getBuildPlateNumber")
if source == self._scene.getRoot():
# we got the root node
num_objects = self._numObjects()
num_objects = self._numObjectsPerBuildPlate()
for build_plate_number in list(self._last_num_objects.keys()) + list(num_objects.keys()):
if build_plate_number not in self._last_num_objects or num_objects[build_plate_number] != self._last_num_objects[build_plate_number]:
self._last_num_objects[build_plate_number] = num_objects[build_plate_number]
@ -604,7 +605,12 @@ class CuraEngineBackend(QObject, Backend):
# See if we need to process the sliced layers job.
active_build_plate = Application.getInstance().getMultiBuildPlateModel().activeBuildPlate
if self._layer_view_active and (self._process_layers_job is None or not self._process_layers_job.isRunning()) and active_build_plate == self._start_slice_job_build_plate:
if (
self._layer_view_active and
(self._process_layers_job is None or not self._process_layers_job.isRunning()) and
active_build_plate == self._start_slice_job_build_plate and
active_build_plate not in self._build_plates_to_be_sliced):
self._startProcessSlicedLayersJob(active_build_plate)
# self._onActiveViewChanged()
self._start_slice_job_build_plate = None
@ -733,7 +739,11 @@ class CuraEngineBackend(QObject, Backend):
# There is data and we're not slicing at the moment
# if we are slicing, there is no need to re-calculate the data as it will be invalid in a moment.
# TODO: what build plate I am slicing
if active_build_plate in self._stored_optimized_layer_data and not self._slicing and not self._process_layers_job:
if (active_build_plate in self._stored_optimized_layer_data and
not self._slicing and
not self._process_layers_job and
active_build_plate not in self._build_plates_to_be_sliced):
self._startProcessSlicedLayersJob(active_build_plate)
else:
self._layer_view_active = False