mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Fixed extruder per gcode layer. Created show_caution preference for gcode reader. CURA-3390
This commit is contained in:
parent
1e75c84662
commit
02bb575ced
2 changed files with 32 additions and 7 deletions
|
@ -10,6 +10,7 @@ from UM.Mesh.MeshReader import MeshReader
|
|||
from UM.Message import Message
|
||||
from UM.Scene.SceneNode import SceneNode
|
||||
from UM.i18n import i18nCatalog
|
||||
from UM.Preferences import Preferences
|
||||
|
||||
catalog = i18nCatalog("cura")
|
||||
|
||||
|
@ -41,6 +42,8 @@ class GCodeReader(MeshReader):
|
|||
self._position = namedtuple('Position', ['x', 'y', 'z', 'e'])
|
||||
self._is_layers_in_file = False
|
||||
|
||||
Preferences.getInstance().addPreference("gcodereader/show_caution", True)
|
||||
|
||||
def _clearValues(self):
|
||||
self._extruder_number = 0
|
||||
self._layer_type = LayerPolygon.Inset0Type
|
||||
|
@ -87,7 +90,7 @@ class GCodeReader(MeshReader):
|
|||
def _getNullBoundingBox():
|
||||
return AxisAlignedBox(minimum=Vector(0, 0, 0), maximum=Vector(10, 10, 10))
|
||||
|
||||
def _createPolygon(self, current_z, path):
|
||||
def _createPolygon(self, current_z, path, nozzle_offset_x = 0, nozzle_offset_y = 0):
|
||||
countvalid = 0
|
||||
for point in path:
|
||||
if point[3] > 0:
|
||||
|
@ -99,6 +102,7 @@ class GCodeReader(MeshReader):
|
|||
self._layer_data_builder.setLayerHeight(self._layer_number, path[0][2])
|
||||
self._layer_data_builder.setLayerThickness(self._layer_number, math.fabs(current_z - self._previous_z))
|
||||
this_layer = self._layer_data_builder.getLayer(self._layer_number)
|
||||
layer_thickness = math.fabs(self._previous_z - current_z) # TODO: use this value
|
||||
except ValueError:
|
||||
return False
|
||||
count = len(path)
|
||||
|
@ -290,14 +294,15 @@ class GCodeReader(MeshReader):
|
|||
T = self._getInt(line, "T")
|
||||
if T is not None:
|
||||
current_position = self._processTCode(T, line, current_position, current_path)
|
||||
if self._createPolygon(current_position[2], current_path):
|
||||
self._layer_number += 1
|
||||
current_path.clear()
|
||||
|
||||
if not self._is_layers_in_file and len(current_path) > 1 and current_position[2] > 0:
|
||||
if self._createPolygon(current_position[2], current_path):
|
||||
self._layer_number += 1
|
||||
current_path.clear()
|
||||
|
||||
|
||||
|
||||
material_color_map = numpy.zeros((10, 4), dtype = numpy.float32)
|
||||
material_color_map[0, :] = [0.0, 0.7, 0.9, 1.0]
|
||||
material_color_map[1, :] = [0.7, 0.9, 0.0, 1.0]
|
||||
|
@ -325,6 +330,7 @@ class GCodeReader(MeshReader):
|
|||
|
||||
Logger.log("d", "Loaded %s" % file_name)
|
||||
|
||||
if Preferences.getInstance().getValue("gcodereader/show_caution"):
|
||||
caution_message = Message(catalog.i18nc(
|
||||
"@info:generic",
|
||||
"Make sure the g-code is suitable for your printer and printer configuration before sending the file to it. The g-code representation may not be accurate."), lifetime=0)
|
||||
|
|
|
@ -273,6 +273,25 @@ UM.PreferencesPage
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
UM.TooltipArea
|
||||
{
|
||||
width: childrenRect.width;
|
||||
height: childrenRect.height;
|
||||
|
||||
text: catalog.i18nc("@info:tooltip","Show caution message in gcode reader.")
|
||||
|
||||
CheckBox
|
||||
{
|
||||
id: gcodeShowCautionCheckbox
|
||||
|
||||
checked: boolCheck(UM.Preferences.getValue("gcodereader/show_caution"))
|
||||
onClicked: UM.Preferences.setValue("gcodereader/show_caution", checked)
|
||||
|
||||
text: catalog.i18nc("@option:check","Caution message in gcode reader");
|
||||
}
|
||||
}
|
||||
|
||||
UM.TooltipArea {
|
||||
width: childrenRect.width
|
||||
height: childrenRect.height
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue