Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Thomas-Karl Pietrowski 2016-01-23 11:14:36 +01:00
commit a676b5df1b
4 changed files with 116 additions and 7 deletions

View file

@ -2,7 +2,109 @@
# Cura is released under the terms of the AGPLv3 or higher.
from UM.Mesh.MeshReader import MeshReader
from UM.Application import Application
from UM.Scene.SceneNode import SceneNode
from UM.Mesh.MeshData import MeshData
from cura.LayerData import LayerData
from cura.LayerDataDecorator import LayerDataDecorator
import os
import numpy
class GCodeReader(MeshReader):
def __init__(self):
super().__init__()
self._supported_extension = ".gcode"
self._scene = Application.getInstance().getController().getScene()
def read(self, file_name):
pass
extension = os.path.splitext(file_name)[1]
if extension.lower() == self._supported_extension:
layer_data = LayerData()
with open (file_name,"rt") as f:
layer = ""
current_path_type = ""
current_layer_nr = 0
poly_list = []
old_position = [0,0,0]
current_z = 0
for line in f:
if line.startswith(';TYPE:'):
current_path_type = line[6:].strip()
#layer_data.addPolygon(current_layer_nr,3 ,None ,5 )
elif line.startswith(';LAYER:'):
current_layer_nr = int(line[7:].strip())
layer_data.addLayer(int(line[7:].strip()))
elif line.startswith(';'):
pass # Ignore comments
else:
command_type = self.getCodeInt(line, 'G')
if command_type == 0 or command_type == 1: #Move command
x = self.getCodeFloat(line, 'X')
y = self.getCodeFloat(line, 'Y')
z = self.getCodeFloat(line, 'Z')
if z:
current_z = z
if x and y:
polygon_data = numpy.zeros((4,3)) #Square :)
polygon_data[0,:] = old_position
polygon_data[1,:] = old_position
polygon_data[2,:] = [x,current_z,y]
polygon_data[3,:] = [x,current_z,y]
old_position = [x,current_z,y]
if current_path_type == "SKIRT":
layer_data.addPolygon(current_layer_nr,5 ,polygon_data ,5 )
elif current_path_type == "WALL-INNER":
layer_data.addPolygon(current_layer_nr,3 ,polygon_data ,5 )
elif current_path_type == "WALL-OUTER":
layer_data.addPolygon(current_layer_nr,1 ,polygon_data ,5 )
else:
layer_data.addPolygon(current_layer_nr,2 ,polygon_data ,5 )
#e = self.getCodeFloat(line, 'E')
#print(x , " ", y , " ", z, " " , e)
pass
layer_data.build()
decorator = LayerDataDecorator()
decorator.setLayerData(layer_data)
new_node = SceneNode()
new_node.setMeshData(MeshData())
new_node.addDecorator(decorator)
new_node.setParent(self._scene.getRoot())
## Gets the value after the 'code' as int
# example: line = "G50" and code is "G" this function will return 50
# \param line string containing g-code.
# \param code string Letter to look for.
# \sa getCodeFloat
# \returns int
def getCodeInt(self, line, code):
n = line.find(code) + 1
if n < 1:
return None
m = line.find(' ', n)
try:
if m < 0:
return int(line[n:])
return int(line[n:m])
except:
return None
## Gets the value after the 'code' as float
# example: line = "G50" and code is "G" this function will return 50
# \param line string containing g-code.
# \param code string Letter to look for.
# \sa getCodeInt
# \returns float
def getCodeFloat(self, line, code):
n = line.find(code) + 1
if n < 1:
return None
m = line.find(' ', n)
try:
if m < 0:
return float(line[n:])
return float(line[n:m])
except:
return None

View file

@ -146,20 +146,27 @@
}
},
"categories": {
"resolution": {
"label": "Quality",
"machine": {
"label": "Machine",
"visible": true,
"icon": "category_layer_height",
"settings": {
"machine_nozzle_size": {
"label": "Nozzle Diameter",
"description": "The inner diameter of the hole in the nozzle.",
"description": "The inner diameter of the nozzle.",
"unit": "mm",
"type": "float",
"default": 0.4,
"min_value": "0.001",
"visible": false
},
}
}
},
"resolution": {
"label": "Quality",
"visible": true,
"icon": "category_layer_height",
"settings": {
"layer_height": {
"label": "Layer Height",
"description": "The height of each layer, in mm. Normal quality prints are 0.1mm, high quality is 0.06mm. You can go up to 0.25mm with an Ultimaker for very fast prints at low quality. For most purposes, layer heights between 0.1 and 0.2mm give a good tradeoff of speed and surface finish.",

View file

@ -63,7 +63,7 @@
]
},
"machine_center_is_zero": { "default": false },
"machine_nozzle_size": { "default": 0.4, "description": "The inner diameter of the hole in the nozzle. If you are using an Olsson Block with a non-standard nozzle then set this field to the nozzle size you are using." },
"machine_nozzle_size": { "default": 0.4, "min_value": "0.001", "description": "The inner diameter of the nozzle. If you are using an Olsson Block with a non-standard nozzle diameter, set this field to the diameter you are using." },
"machine_nozzle_heat_up_speed": { "default": 2.0 },
"machine_nozzle_cool_down_speed": { "default": 2.0 },
"gantry_height": { "default": 55 },

View file

@ -30,7 +30,7 @@ UM.PreferencesPage
width: childrenRect.width;
height: childrenRect.height;
text: catalog.i18nc("@info:tooltip","Highlight unsupported areas of the model in red. Without support these areas will nog print properly.")
text: catalog.i18nc("@info:tooltip","Highlight unsupported areas of the model in red. Without support these areas will not print properly.")
CheckBox
{