mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 02:16:01 +08:00
Merge branch 'master' of https://github.com/Ultimaker/Cura
This commit is contained in:
commit
a1885fc4fe
@ -42,7 +42,8 @@ class CuraEngineBackend(Backend):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
# Find out where the engine is located, and how it is called. This depends on how Cura is packaged and which OS we are running on.
|
||||
# Find out where the engine is located, and how it is called.
|
||||
# This depends on how Cura is packaged and which OS we are running on.
|
||||
default_engine_location = os.path.join(Application.getInstallPrefix(), "bin", "CuraEngine")
|
||||
if hasattr(sys, "frozen"):
|
||||
default_engine_location = os.path.join(os.path.dirname(os.path.abspath(sys.executable)), "CuraEngine")
|
||||
@ -121,7 +122,8 @@ class CuraEngineBackend(Backend):
|
||||
json_path = Resources.getPath(Resources.DefinitionContainers, "fdmprinter.def.json")
|
||||
return [Preferences.getInstance().getValue("backend/location"), "connect", "127.0.0.1:{0}".format(self._port), "-j", json_path, ""]
|
||||
|
||||
## Emitted when we get a message containing print duration and material amount. This also implies the slicing has finished.
|
||||
## Emitted when we get a message containing print duration and material amount.
|
||||
# This also implies the slicing has finished.
|
||||
# \param time The amount of time the print will take.
|
||||
# \param material_amount The amount of material the print will use.
|
||||
printDurationMessage = Signal()
|
||||
@ -206,7 +208,7 @@ class CuraEngineBackend(Backend):
|
||||
|
||||
if job.getResult() == StartSliceJob.StartJobResult.SettingError:
|
||||
if Application.getInstance().getPlatformActivity:
|
||||
self._error_message = Message(catalog.i18nc("@info:status", "Unable to slice. Please check your setting values for errors."), lifetime = 10)
|
||||
self._error_message = Message(catalog.i18nc("@info:status", "Unable to slice. Please check your setting values for errors."))
|
||||
self._error_message.show()
|
||||
self.backendStateChange.emit(BackendState.Error)
|
||||
else:
|
||||
@ -215,7 +217,7 @@ class CuraEngineBackend(Backend):
|
||||
|
||||
if job.getResult() == StartSliceJob.StartJobResult.NothingToSlice:
|
||||
if Application.getInstance().getPlatformActivity:
|
||||
self._error_message = Message(catalog.i18nc("@info:status", "Unable to slice. No suitable objects found."), lifetime = 10)
|
||||
self._error_message = Message(catalog.i18nc("@info:status", "Unable to slice. No suitable objects found."))
|
||||
self._error_message.show()
|
||||
self.backendStateChange.emit(BackendState.Error)
|
||||
else:
|
||||
@ -318,7 +320,7 @@ class CuraEngineBackend(Backend):
|
||||
|
||||
## Called when a print time message is received from the engine.
|
||||
#
|
||||
# \param message The protobuf message containing the print time and
|
||||
# \param message The protobuff message containing the print time and
|
||||
# material amount per extruder
|
||||
def _onPrintTimeMaterialEstimates(self, message):
|
||||
material_amounts = []
|
||||
|
@ -56,10 +56,9 @@ class ProcessSlicedLayersJob(Job):
|
||||
|
||||
## Remove old layer data (if any)
|
||||
for node in DepthFirstIterator(self._scene.getRoot()):
|
||||
if type(node) is SceneNode and node.getMeshData():
|
||||
if node.callDecoration("getLayerData"):
|
||||
self._scene.getRoot().removeChild(node)
|
||||
Job.yieldThread()
|
||||
node.getParent().removeChild(node)
|
||||
break
|
||||
if self._abort_requested:
|
||||
if self._progress:
|
||||
self._progress.hide()
|
||||
@ -74,7 +73,7 @@ class ProcessSlicedLayersJob(Job):
|
||||
# instead simply offset all other layers so the lowest layer is always 0.
|
||||
min_layer_number = 0
|
||||
for layer in self._layers:
|
||||
if(layer.id < min_layer_number):
|
||||
if layer.id < min_layer_number:
|
||||
min_layer_number = layer.id
|
||||
|
||||
current_layer = 0
|
||||
@ -117,7 +116,6 @@ class ProcessSlicedLayersJob(Job):
|
||||
new_points[:, 1] = points[:, 2]
|
||||
new_points[:, 2] = -points[:, 1]
|
||||
|
||||
|
||||
this_poly = LayerPolygon.LayerPolygon(layer_data, extruder, line_types, new_points, line_widths)
|
||||
this_poly.buildCache()
|
||||
|
||||
@ -185,4 +183,3 @@ class ProcessSlicedLayersJob(Job):
|
||||
else:
|
||||
if self._progress:
|
||||
self._progress.hide()
|
||||
|
||||
|
@ -25,6 +25,7 @@ class StartJobResult(IntEnum):
|
||||
SettingError = 3
|
||||
NothingToSlice = 4
|
||||
|
||||
|
||||
## Formatter class that handles token expansion in start/end gcod
|
||||
class GcodeStartEndFormatter(Formatter):
|
||||
def get_value(self, key, args, kwargs): # [CodeStyle: get_value is an overridden function from the Formatter class]
|
||||
@ -38,6 +39,7 @@ class GcodeStartEndFormatter(Formatter):
|
||||
Logger.log("w", "Incorrectly formatted placeholder '%s' in start/end gcode", key)
|
||||
return "{" + str(key) + "}"
|
||||
|
||||
|
||||
## Job class that builds up the message of scene data to send to CuraEngine.
|
||||
class StartSliceJob(Job):
|
||||
def __init__(self, slice_message):
|
||||
@ -124,6 +126,9 @@ class StartSliceJob(Job):
|
||||
if temp_list:
|
||||
object_groups.append(temp_list)
|
||||
|
||||
# There are cases when there is nothing to slice. This can happen due to one at a time slicing not being
|
||||
# able to find a possible sequence or because there are no objects on the build plate (or they are outside
|
||||
# the build volume)
|
||||
if not object_groups:
|
||||
self.setResult(StartJobResult.NothingToSlice)
|
||||
return
|
||||
@ -172,6 +177,7 @@ class StartSliceJob(Job):
|
||||
Logger.logException("w", "Unable to do token replacement on start/end gcode")
|
||||
return str(value).encode("utf-8")
|
||||
|
||||
## Create extruder message from stack
|
||||
def _buildExtruderMessage(self, stack):
|
||||
message = self._slice_message.addRepeatedMessage("extruders")
|
||||
message.id = int(stack.getMetaDataEntry("position"))
|
||||
@ -210,6 +216,9 @@ class StartSliceJob(Job):
|
||||
else:
|
||||
setting_message.value = str(value).encode("utf-8")
|
||||
|
||||
## Check if a node has per object settings and ensure that they are set correctly in the message
|
||||
# \param node \type{SceneNode} Node to check.
|
||||
# \param message object_lists message to put the per object settings in
|
||||
def _handlePerObjectSettings(self, node, message):
|
||||
stack = node.callDecoration("getStack")
|
||||
# Check if the node has a stack attached to it and the stack has any settings in the top container.
|
||||
@ -231,6 +240,9 @@ class StartSliceJob(Job):
|
||||
setting.value = str(stack.getProperty(key, "value")).encode("utf-8")
|
||||
Job.yieldThread()
|
||||
|
||||
## Recursive function to put all settings that require eachother for value changes in a list
|
||||
# \param relations_set \type{set} Set of keys (strings) of settings that are influenced
|
||||
# \param relations list of relation objects that need to be checked.
|
||||
def _addRelations(self, relations_set, relations):
|
||||
for relation in filter(lambda r: r.role == "value", relations):
|
||||
if relation.type == RelationType.RequiresTarget:
|
||||
|
Loading…
x
Reference in New Issue
Block a user