Merge branch 'master' of https://github.com/Ultimaker/Cura into layerview_dev

This commit is contained in:
Johan K 2016-07-22 10:21:41 +02:00
commit c6790981d6
37 changed files with 835 additions and 316 deletions

View file

@ -22,6 +22,7 @@ from . import StartSliceJob
import os
import sys
from time import time
from PyQt5.QtCore import QTimer
@ -91,6 +92,7 @@ class CuraEngineBackend(Backend):
self._always_restart = True #Always restart the engine when starting a new slice. Don't keep the process running. TODO: Fix engine statelessness.
self._process_layers_job = None #The currently active job to process layers, or None if it is not processing layers.
self._backend_log_max_lines = 200 # Maximal count of lines to buffer
self._error_message = None #Pop-up message that shows errors.
self.backendQuit.connect(self._onBackendQuit)
@ -100,6 +102,8 @@ class CuraEngineBackend(Backend):
Application.getInstance().getController().toolOperationStarted.connect(self._onToolOperationStarted)
Application.getInstance().getController().toolOperationStopped.connect(self._onToolOperationStopped)
self._slice_start_time = None
## Called when closing the application.
#
# This function should terminate the engine process.
@ -128,6 +132,7 @@ class CuraEngineBackend(Backend):
## Perform a slice of the scene.
def slice(self):
self._slice_start_time = time()
if not self._enabled or not self._global_container_stack: #We shouldn't be slicing.
# try again in a short time
self._change_timer.start()
@ -217,6 +222,7 @@ class CuraEngineBackend(Backend):
# Preparation completed, send it to the backend.
self._socket.sendMessage(job.getSliceMessage())
Logger.log("d", "Sending slice message took %s seconds", time() - self._slice_start_time )
## Listener for when the scene has changed.
#
@ -286,7 +292,7 @@ class CuraEngineBackend(Backend):
self.processingProgress.emit(1.0)
self._slicing = False
Logger.log("d", "Slicing took %s seconds", time() - self._slice_start_time )
if self._layer_view_active and (self._process_layers_job is None or not self._process_layers_job.isRunning()):
self._process_layers_job = ProcessSlicedLayersJob.ProcessSlicedLayersJob(self._stored_optimized_layer_data)
self._process_layers_job.start()

View file

@ -9,6 +9,7 @@ from UM.Mesh.MeshData import MeshData
from UM.Message import Message
from UM.i18n import i18nCatalog
from UM.Logger import Logger
from UM.Math.Vector import Vector
@ -17,7 +18,7 @@ from cura import LayerDataDecorator
from cura import LayerPolygon
import numpy
from time import time
catalog = i18nCatalog("cura")
@ -45,6 +46,7 @@ class ProcessSlicedLayersJob(Job):
if len(self._layers) == 0:
return
start_time = time()
if Application.getInstance().getController().getActiveView().getPluginId() == "LayerView":
self._progress = Message(catalog.i18nc("@info:status", "Processing Layers"), 0, False, -1)
self._progress.show()
@ -155,7 +157,10 @@ class ProcessSlicedLayersJob(Job):
new_node.addDecorator(decorator)
new_node.setMeshData(mesh)
new_node.setParent(self._scene.getRoot()) # Note: After this we can no longer abort!
# Set build volume as parent, the build volume can move as a result of raft settings.
# It makes sense to set the build volume as parent: the print is actually printed on it.
new_node_parent = Application.getInstance().getBuildVolume()
new_node.setParent(new_node_parent) # Note: After this we can no longer abort!
settings = Application.getInstance().getGlobalContainerStack()
if not settings.getProperty("machine_center_is_zero", "value"):
@ -174,6 +179,8 @@ class ProcessSlicedLayersJob(Job):
# Clear the unparsed layers. This saves us a bunch of memory if the Job does not get destroyed.
self._layers = None
Logger.log("d", "Processing layers took %s seconds", time() - start_time)
def _onActiveViewChanged(self):
if self.isRunning():
if Application.getInstance().getController().getActiveView().getPluginId() == "LayerView":

View file

@ -129,7 +129,7 @@ class StartSliceJob(Job):
self._buildGlobalSettingsMessage(stack)
for extruder_stack in cura.Settings.ExtruderManager.getInstance().getMachineExtruders(stack.getBottom().getId()):
for extruder_stack in cura.Settings.ExtruderManager.getInstance().getMachineExtruders(stack.getId()):
self._buildExtruderMessage(extruder_stack)
for group in object_groups:
@ -174,10 +174,17 @@ class StartSliceJob(Job):
def _buildExtruderMessage(self, stack):
message = self._slice_message.addRepeatedMessage("extruders")
message.id = int(stack.getMetaDataEntry("position"))
material_instance_container = stack.findContainer({"type": "material"})
for key in stack.getAllKeys():
setting = message.getMessage("settings").addRepeatedMessage("settings")
setting.name = key
setting.value = str(stack.getProperty(key, "value")).encode("utf-8")
if key == "material_guid" and material_instance_container:
# Also send the material GUID. This is a setting in fdmprinter, but we have no interface for it.
setting.value = str(material_instance_container.getMetaDataEntry("GUID", "")).encode("utf-8")
else:
setting.value = str(stack.getProperty(key, "value")).encode("utf-8")
Job.yieldThread()
## Sends all global settings to the engine.