This commit is contained in:
fieldOfView 2016-07-18 09:41:50 +02:00
commit 935481e05f
9 changed files with 125 additions and 76 deletions

View File

@ -585,18 +585,16 @@ class CuraApplication(QtApplication):
node = Selection.getSelectedObject(0) node = Selection.getSelectedObject(0)
if node: if node:
current_node = node
# Find the topmost group
while current_node.getParent() and current_node.getParent().callDecoration("isGroup"):
current_node = current_node.getParent()
new_node = copy.deepcopy(current_node)
op = GroupedOperation() op = GroupedOperation()
for _ in range(count): for _ in range(count):
if node.getParent() and node.getParent().callDecoration("isGroup"): op.addOperation(AddSceneNodeOperation(new_node, current_node.getParent()))
new_node = copy.deepcopy(node.getParent()) #Copy the group node.
new_node.callDecoration("recomputeConvexHull")
op.addOperation(AddSceneNodeOperation(new_node,node.getParent().getParent()))
else:
new_node = copy.deepcopy(node)
new_node.callDecoration("recomputeConvexHull")
op.addOperation(AddSceneNodeOperation(new_node, node.getParent()))
op.push() op.push()
## Center object on platform. ## Center object on platform.

View File

@ -7,6 +7,8 @@ from UM.Application import Application
from UM.Qt.Duration import Duration from UM.Qt.Duration import Duration
from UM.Preferences import Preferences from UM.Preferences import Preferences
import cura.Settings.ExtruderManager
import math import math
import os.path import os.path
import unicodedata import unicodedata
@ -44,7 +46,8 @@ class PrintInformation(QObject):
self._current_print_time = Duration(None, self) self._current_print_time = Duration(None, self)
self._material_amounts = [] self._material_lengths = []
self._material_weights = []
self._backend = Application.getInstance().getBackend() self._backend = Application.getInstance().getBackend()
if self._backend: if self._backend:
@ -62,11 +65,17 @@ class PrintInformation(QObject):
def currentPrintTime(self): def currentPrintTime(self):
return self._current_print_time return self._current_print_time
materialAmountsChanged = pyqtSignal() materialLengthsChanged = pyqtSignal()
@pyqtProperty("QVariantList", notify = materialAmountsChanged) @pyqtProperty("QVariantList", notify = materialLengthsChanged)
def materialAmounts(self): def materialLengths(self):
return self._material_amounts return self._material_lengths
materialWeightsChanged = pyqtSignal()
@pyqtProperty("QVariantList", notify = materialWeightsChanged)
def materialWeights(self):
return self._material_weights
def _onPrintDurationMessage(self, total_time, material_amounts): def _onPrintDurationMessage(self, total_time, material_amounts):
self._current_print_time.setDuration(total_time) self._current_print_time.setDuration(total_time)
@ -74,13 +83,24 @@ class PrintInformation(QObject):
# Material amount is sent as an amount of mm^3, so calculate length from that # Material amount is sent as an amount of mm^3, so calculate length from that
r = Application.getInstance().getGlobalContainerStack().getProperty("material_diameter", "value") / 2 r = Application.getInstance().getGlobalContainerStack().getProperty("material_diameter", "value") / 2
self._material_amounts = [] self._material_lengths = []
for amount in material_amounts: self._material_weights = []
self._material_amounts.append(round((amount / (math.pi * r ** 2)) / 1000, 2)) extruder_stacks = list(cura.Settings.ExtruderManager.getInstance().getMachineExtruders(Application.getInstance().getGlobalContainerStack().getId()))
self.materialAmountsChanged.emit() for index, amount in enumerate(material_amounts):
## Find the right extruder stack. As the list isn't sorted because it's a annoying generator, we do some
# list comprehension filtering to solve this for us.
extruder_stack = [extruder for extruder in extruder_stacks if extruder.getMetaDataEntry("position") == str(index)][0]
density = extruder_stack.getMetaDataEntry("properties", {}).get("density", 0)
self._material_weights.append(float(amount) * float(density))
self._material_lengths.append(round((amount / (math.pi * r ** 2)) / 1000, 2))
self.materialLengthsChanged.emit()
self.materialWeightsChanged.emit()
@pyqtSlot(str) @pyqtSlot(str)
def setJobName(self, name): def setJobName(self, name):
# Ensure that we don't use entire path but only filename
name = os.path.basename(name)
# when a file is opened using the terminal; the filename comes from _onFileLoaded and still contains its # when a file is opened using the terminal; the filename comes from _onFileLoaded and still contains its
# extension. This cuts the extension off if necessary. # extension. This cuts the extension off if necessary.
name = os.path.splitext(name)[0] name = os.path.splitext(name)[0]

View File

@ -126,6 +126,9 @@ class MachineManager(QObject):
self._auto_change_material_hotend_flood_time = time.time() self._auto_change_material_hotend_flood_time = time.time()
self._auto_change_material_hotend_flood_last_choice = button self._auto_change_material_hotend_flood_last_choice = button
if button == QMessageBox.No:
return
Logger.log("d", "Setting hotend variant of hotend %d to %s" % (index, hotend_id)) Logger.log("d", "Setting hotend variant of hotend %d to %s" % (index, hotend_id))
extruder_manager = ExtruderManager.getInstance() extruder_manager = ExtruderManager.getInstance()
@ -174,6 +177,9 @@ class MachineManager(QObject):
self._auto_change_material_hotend_flood_time = time.time() self._auto_change_material_hotend_flood_time = time.time()
self._auto_change_material_hotend_flood_last_choice = button self._auto_change_material_hotend_flood_last_choice = button
if button == QMessageBox.No:
return
Logger.log("d", "Setting material of hotend %d to %s" % (index, material_id)) Logger.log("d", "Setting material of hotend %d to %s" % (index, material_id))
extruder_manager = ExtruderManager.getInstance() extruder_manager = ExtruderManager.getInstance()
@ -493,6 +499,7 @@ class MachineManager(QObject):
self.activeQualityChanged.emit() self.activeQualityChanged.emit()
@pyqtSlot(str) @pyqtSlot(str)
@pyqtSlot()
def updateQualityContainerFromUserContainer(self, quality_id = None): def updateQualityContainerFromUserContainer(self, quality_id = None):
if not self._active_container_stack: if not self._active_container_stack:
return return

View File

@ -180,6 +180,12 @@ class StartSliceJob(Job):
setting.value = str(stack.getProperty(key, "value")).encode("utf-8") setting.value = str(stack.getProperty(key, "value")).encode("utf-8")
Job.yieldThread() Job.yieldThread()
# ALso send the material GUID as a setting.
material_instance_container = stack.findContainer({"type": "material"})
if material_instance_container:
setting = message.getMessage("settings").addRepeatedMessage("settings")
setting.name = "material_GUID"
setting.value = str(material_instance_container.getMetaDataEntry("GUID", "")).encode("utf-8")
## Sends all global settings to the engine. ## Sends all global settings to the engine.
# #
# The settings are taken from the global stack. This does not include any # The settings are taken from the global stack. This does not include any

View File

@ -59,7 +59,7 @@ class SliceInfo(Extension):
material_radius = 0.5 * global_container_stack.getProperty("material_diameter", "value") material_radius = 0.5 * global_container_stack.getProperty("material_diameter", "value")
# TODO: Send material per extruder instead of mashing it on a pile # TODO: Send material per extruder instead of mashing it on a pile
material_used = math.pi * material_radius * material_radius * sum(print_information.materialAmounts) #Volume of all materials used material_used = math.pi * material_radius * material_radius * sum(print_information.materialLengths) #Volume of all materials used
# Get model information (bounding boxes, hashes and transformation matrix) # Get model information (bounding boxes, hashes and transformation matrix)
models_info = [] models_info = []

View File

@ -196,8 +196,8 @@ Cura.MachineAction
visible: checkupMachineAction.usbConnected visible: checkupMachineAction.usbConnected
Button Button
{ {
height: 20
text: checkupMachineAction.heatupHotendStarted ? catalog.i18nc("@action:button","Stop Heating") : catalog.i18nc("@action:button","Start Heating") text: checkupMachineAction.heatupHotendStarted ? catalog.i18nc("@action:button","Stop Heating") : catalog.i18nc("@action:button","Start Heating")
//
onClicked: onClicked:
{ {
if (checkupMachineAction.heatupHotendStarted) if (checkupMachineAction.heatupHotendStarted)
@ -259,6 +259,7 @@ Cura.MachineAction
Button Button
{ {
text: checkupMachineAction.heatupBedStarted ?catalog.i18nc("@action:button","Stop Heating") : catalog.i18nc("@action:button","Start Heating") text: checkupMachineAction.heatupBedStarted ?catalog.i18nc("@action:button","Stop Heating") : catalog.i18nc("@action:button","Start Heating")
height: 20
onClicked: onClicked:
{ {
if (checkupMachineAction.heatupBedStarted) if (checkupMachineAction.heatupBedStarted)

View File

@ -145,30 +145,6 @@
"settable_per_meshgroup": false, "settable_per_meshgroup": false,
"settable_globally": false "settable_globally": false
}, },
"extruder_prime_pos_x":
{
"label": "Extruder Prime X Position",
"description": "The X coordinate of the position where the nozzle primes at the start of printing.",
"type": "float",
"unit": "mm",
"default_value": 0,
"minimum_value_warning": "machine_nozzle_offset_x",
"maximum_value_warning": "machine_width",
"settable_per_mesh": false,
"settable_per_extruder": true
},
"extruder_prime_pos_y":
{
"label": "Extruder Prime Y Position",
"description": "The Y coordinate of the position where the nozzle primes at the start of printing.",
"type": "float",
"unit": "mm",
"default_value": 0,
"minimum_value_warning": "machine_nozzle_offset_y",
"maximum_value_warning": "machine_depth",
"settable_per_mesh": false,
"settable_per_extruder": true
},
"extruder_prime_pos_z": "extruder_prime_pos_z":
{ {
"label": "Extruder Prime Z Position", "label": "Extruder Prime Z Position",
@ -182,6 +158,42 @@
"settable_per_extruder": true "settable_per_extruder": true
} }
} }
},
"platform_adhesion":
{
"label": "Platform Adhesion",
"type": "category",
"icon": "category_adhesion",
"description": "Adhesion",
"children":
{
"extruder_prime_pos_x":
{
"label": "Extruder Prime X Position",
"description": "The X coordinate of the position where the nozzle primes at the start of printing.",
"type": "float",
"unit": "mm",
"default_value": 0,
"minimum_value_warning": "machine_nozzle_offset_x",
"maximum_value_warning": "machine_width",
"settable_per_mesh": false,
"settable_per_extruder": true,
"enabled": false
},
"extruder_prime_pos_y":
{
"label": "Extruder Prime Y Position",
"description": "The Y coordinate of the position where the nozzle primes at the start of printing.",
"type": "float",
"unit": "mm",
"default_value": 0,
"minimum_value_warning": "machine_nozzle_offset_y",
"maximum_value_warning": "machine_depth",
"settable_per_mesh": false,
"settable_per_extruder": true,
"enabled": false
}
}
} }
} }
} }

View File

@ -326,30 +326,6 @@
"settable_per_extruder": false, "settable_per_extruder": false,
"settable_per_meshgroup": false "settable_per_meshgroup": false
}, },
"extruder_prime_pos_x":
{
"label": "Extruder Prime X Position",
"description": "The X coordinate of the position where the nozzle primes at the start of printing.",
"type": "float",
"unit": "mm",
"default_value": 0,
"minimum_value_warning": "0",
"maximum_value_warning": "machine_width",
"settable_per_mesh": false,
"settable_per_extruder": true
},
"extruder_prime_pos_y":
{
"label": "Extruder Prime Y Position",
"description": "The Y coordinate of the position where the nozzle primes at the start of printing.",
"type": "float",
"unit": "mm",
"default_value": 0,
"minimum_value_warning": "0",
"maximum_value_warning": "machine_depth",
"settable_per_mesh": false,
"settable_per_extruder": true
},
"extruder_prime_pos_z": "extruder_prime_pos_z":
{ {
"label": "Extruder Prime Z Position", "label": "Extruder Prime Z Position",
@ -904,7 +880,7 @@
"type": "float", "type": "float",
"default_value": 2, "default_value": 2,
"minimum_value": "0", "minimum_value": "0",
"value": "0 if infill_sparse_density == 0 else (infill_line_width * 100) / infill_sparse_density * (2 if infill_pattern == \"grid\" else (3 if infill_pattern == \"triangles\" else 1))", "value": "0 if infill_sparse_density == 0 else (infill_line_width * 100) / infill_sparse_density * (2 if infill_pattern == \"grid\" else (3 if infill_pattern == \"triangles\" or infill_pattern == \"cubic\" else (4 if infill_pattern == \"tetrahedral\" else 1)))",
"settable_per_mesh": true "settable_per_mesh": true
} }
} }
@ -912,13 +888,15 @@
"infill_pattern": "infill_pattern":
{ {
"label": "Infill Pattern", "label": "Infill Pattern",
"description": "The pattern of the infill material of the print. The line and zig zag infill swap direction on alternate layers, reducing material cost. The grid, triangle and concentric patterns are fully printed every layer.", "description": "The pattern of the infill material of the print. The line and zig zag infill swap direction on alternate layers, reducing material cost. The grid, triangle, cubic, tetrahedral and concentric patterns are fully printed every layer. Cubic and tetrahedral infill change with every layer to provide a more equal distribution of strength over each direction.",
"type": "enum", "type": "enum",
"options": "options":
{ {
"grid": "Grid", "grid": "Grid",
"lines": "Lines", "lines": "Lines",
"triangles": "Triangles", "triangles": "Triangles",
"cubic": "Cubic",
"tetrahedral": "Tetrahedral",
"concentric": "Concentric", "concentric": "Concentric",
"zigzag": "Zig Zag" "zigzag": "Zig Zag"
}, },
@ -2446,6 +2424,32 @@
"description": "Adhesion", "description": "Adhesion",
"children": "children":
{ {
"extruder_prime_pos_x":
{
"label": "Extruder Prime X Position",
"description": "The X coordinate of the position where the nozzle primes at the start of printing.",
"type": "float",
"unit": "mm",
"default_value": 0,
"minimum_value_warning": "0",
"maximum_value_warning": "machine_width",
"settable_per_mesh": false,
"settable_per_extruder": true,
"enabled": false
},
"extruder_prime_pos_y":
{
"label": "Extruder Prime Y Position",
"description": "The Y coordinate of the position where the nozzle primes at the start of printing.",
"type": "float",
"unit": "mm",
"default_value": 0,
"minimum_value_warning": "0",
"maximum_value_warning": "machine_depth",
"settable_per_mesh": false,
"settable_per_extruder": true,
"enabled": false
},
"adhesion_type": "adhesion_type":
{ {
"label": "Platform Adhesion Type", "label": "Platform Adhesion Type",
@ -2998,7 +3002,7 @@
"type": "extruder", "type": "extruder",
"default_value": "0", "default_value": "0",
"value": "support_extruder_nr", "value": "support_extruder_nr",
"enabled": "support_enable", "enabled": "support_enable and support_roof_enable",
"settable_per_mesh": false, "settable_per_mesh": false,
"settable_per_extruder": false "settable_per_extruder": false
} }

View File

@ -24,7 +24,8 @@ Rectangle {
UM.I18nCatalog { id: catalog; name:"cura"} UM.I18nCatalog { id: catalog; name:"cura"}
property variant printDuration: PrintInformation.currentPrintTime property variant printDuration: PrintInformation.currentPrintTime
property variant printMaterialAmounts: PrintInformation.materialAmounts property variant printMaterialLengths: PrintInformation.materialLengths
property variant printMaterialWeights: PrintInformation.materialWeights
height: childrenRect.height height: childrenRect.height
color: "transparent" color: "transparent"
@ -195,9 +196,9 @@ Rectangle {
text: text:
{ {
var amounts = []; var amounts = [];
if(base.printMaterialAmounts) { if(base.printMaterialLengths) {
for(var index = 0; index < base.printMaterialAmounts.length; index++) { for(var index = 0; index < base.printMaterialLengths.length; index++) {
amounts.push(base.printMaterialAmounts[index].toFixed(2)); amounts.push(base.printMaterialLengths[index].toFixed(2));
} }
} else { } else {
amounts = ["0.00"]; amounts = ["0.00"];