Send all global_inherits_stack to engine

Only the settings for which global_inherits_stack is set should be sent to the engine.

Contributes to issue CURA-2011.
This commit is contained in:
Ghostkeeper 2016-07-29 16:22:18 +02:00
parent fb96950762
commit b21a1f311a
No known key found for this signature in database
GPG key ID: 701948C5954A7385
2 changed files with 24 additions and 1 deletions

View file

@ -13,6 +13,7 @@ message Slice
repeated ObjectList object_lists = 1; // The meshgroups to be printed one after another repeated ObjectList object_lists = 1; // The meshgroups to be printed one after another
SettingList global_settings = 2; // The global settings used for the whole print job SettingList global_settings = 2; // The global settings used for the whole print job
repeated Extruder extruders = 3; // The settings sent to each extruder object repeated Extruder extruders = 3; // The settings sent to each extruder object
repeated SettingExtruder global_inherits_stack = 4; //From which stack the setting would inherit if not defined in a stack.
} }
message Extruder message Extruder
@ -108,8 +109,14 @@ message Setting {
bytes value = 2; // The value of the setting bytes value = 2; // The value of the setting
} }
message SettingExtruder {
string name = 1; //The setting key.
int32 extruder = 2; //From which extruder stack the setting should inherit.
}
message GCodePrefix { message GCodePrefix {
bytes data = 2; // Header string to be prenpended before the rest of the gcode sent from the engine bytes data = 2; //Header string to be prepended before the rest of the g-code sent from the engine.
} }
message SlicingFinished { message SlicingFinished {

View file

@ -134,6 +134,7 @@ class StartSliceJob(Job):
return return
self._buildGlobalSettingsMessage(stack) self._buildGlobalSettingsMessage(stack)
self._buildGlobalInheritsStackMessage(stack)
for extruder_stack in cura.Settings.ExtruderManager.getInstance().getMachineExtruders(stack.getId()): for extruder_stack in cura.Settings.ExtruderManager.getInstance().getMachineExtruders(stack.getId()):
self._buildExtruderMessage(extruder_stack) self._buildExtruderMessage(extruder_stack)
@ -216,6 +217,21 @@ class StartSliceJob(Job):
else: else:
setting_message.value = str(value).encode("utf-8") setting_message.value = str(value).encode("utf-8")
## Sends for some settings which extruder they should fallback to if not
# set.
#
# This is only set for settings that have the global_inherits_stack
# property.
#
# \param stack The global stack with all settings, from which to read the
# global_inherits_stack property.
def _buildGlobalInheritsStackMessage(self, stack):
for key in stack.getAllKeys():
if stack.hasProperty(key, "global_inherits_stack"):
setting_extruder = self._slice_message.addRepeatedMessage("global_inherits_stack")
setting_extruder.name = key
setting_extruder.extruder = int(stack.getProperty(key, "global_inherits_stack"))
## Check if a node has per object settings and ensure that they are set correctly in the message ## 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 node \type{SceneNode} Node to check.
# \param message object_lists message to put the per object settings in # \param message object_lists message to put the per object settings in