from newui import util3d
+class gcodePath():
+ def __init__(self, newType, pathType, layerNr, startPoint):
+ self.type = newType
+ self.pathType = pathType
+ self.list = [startPoint]
+ self.layerNr = layerNr
+
class gcode():
def __init__(self):
self.regMatch = {}
pathType = 'CUSTOM';
layerNr = 0; #Note layer 0 will be the start code.
startCodeDone = False
- currentPath = {'type': 'move', 'pathType': pathType, 'list': [pos.copy()], 'layerNr': layerNr}
- currentPath['list'][-1].e = totalExtrusion
+ currentPath = gcodePath('move', pathType, layerNr, pos.copy())
+ currentPath.list[0].e = totalExtrusion
+ pathList.append(currentPath)
for line in gcodeFile:
if filePos != gcodeFile.tell():
filePos = gcodeFile.tell()
currentE += e
if totalExtrusion > maxExtrusion:
maxExtrusion = totalExtrusion
- if currentPath['type'] != moveType or currentPath['pathType'] != pathType:
+ if currentPath.type != moveType or currentPath.pathType != pathType:
+ currentPath = gcodePath(moveType, pathType, layerNr, currentPath.list[-1])
pathList.append(currentPath)
- currentPath = {'type': moveType, 'pathType': pathType, 'list': [currentPath['list'][-1]], 'layerNr': layerNr}
- currentPath['list'].append(pos.copy())
- currentPath['list'][-1].e = totalExtrusion
+ newPos = pos.copy()
+ newPos.e = totalExtrusion
+ currentPath.list.append(newPos)
elif G == 20: #Units are inches
scale = 25.4
elif G == 21: #Units are mm
\r
curLayerNum = 0\r
for path in self.parent.gcode.pathList:\r
- if path['layerNr'] != curLayerNum:\r
+ if path.layerNr != curLayerNum:\r
prevLayerZ = curLayerZ\r
- curLayerZ = path['list'][1].z\r
- curLayerNum = path['layerNr']\r
+ curLayerZ = path.list[1].z\r
+ curLayerNum = path.layerNr\r
layerThickness = curLayerZ - prevLayerZ\r
\r
c = 1.0\r
- if path['layerNr'] != self.parent.layerSpin.GetValue():\r
- if path['layerNr'] < self.parent.layerSpin.GetValue():\r
- c = 0.9 - (self.parent.layerSpin.GetValue() - path['layerNr']) * 0.1\r
+ if path.layerNr != self.parent.layerSpin.GetValue():\r
+ if path.layerNr < self.parent.layerSpin.GetValue():\r
+ c = 0.9 - (self.parent.layerSpin.GetValue() - path.layerNr) * 0.1\r
if c < 0.4:\r
c = 0.4\r
else:\r
break\r
- if path['type'] == 'move':\r
+ if path.type == 'move':\r
glColor3f(0,0,c)\r
- if path['type'] == 'extrude':\r
- if path['pathType'] == 'FILL':\r
+ if path.type == 'extrude':\r
+ if path.pathType == 'FILL':\r
glColor3f(c/2,c/2,0)\r
- elif path['pathType'] == 'WALL-INNER':\r
+ elif path.pathType == 'WALL-INNER':\r
glColor3f(0,c,0)\r
else:\r
glColor3f(c,0,0)\r
- if path['type'] == 'retract':\r
+ if path.type == 'retract':\r
glColor3f(0,c,c)\r
- if c > 0.4 and path['type'] == 'extrude':\r
- for i in xrange(0, len(path['list'])-1):\r
- v0 = path['list'][i]\r
- v1 = path['list'][i+1]\r
+ if c > 0.4 and path.type == 'extrude':\r
+ for i in xrange(0, len(path.list)-1):\r
+ v0 = path.list[i]\r
+ v1 = path.list[i+1]\r
\r
# Calculate line width from ePerDistance (needs layer thickness and filament diameter)\r
dist = (v0 - v1).vsize()\r
v1 = v1 - normal * lineWidth\r
\r
glBegin(GL_QUADS)\r
- if path['pathType'] == 'FILL': #Remove depth buffer fighting on infill/wall overlap\r
+ if path.pathType == 'FILL': #Remove depth buffer fighting on infill/wall overlap\r
glVertex3f(v0.x, v0.y, v0.z - 0.02)\r
glVertex3f(v1.x, v1.y, v1.z - 0.02)\r
glVertex3f(v3.x, v3.y, v3.z - 0.02)\r
# glEnd()\r
else:\r
glBegin(GL_LINE_STRIP)\r
- for v in path['list']:\r
+ for v in path.list:\r
glVertex3f(v.x, v.y, v.z)\r
glEnd()\r
glEndList()\r