chiark / gitweb /
Document all util files.
authordaid <daid303@gmail.com>
Fri, 14 Feb 2014 07:54:19 +0000 (08:54 +0100)
committerdaid <daid303@gmail.com>
Fri, 14 Feb 2014 07:54:19 +0000 (08:54 +0100)
Cura/gui/aboutWindow.py
Cura/util/drawingLoader/__init__.py [deleted file]
Cura/util/drawingLoader/drawing.py [deleted file]
Cura/util/drawingLoader/dxf.py [deleted file]
Cura/util/drawingLoader/svg.py [deleted file]
Cura/util/printerConnection/doodle3dConnect.py
Cura/util/printerConnection/dummyConnection.py
Cura/util/printerConnection/printerConnectionBase.py
Cura/util/printerConnection/printerConnectionManager.py
Cura/util/printerConnection/serialConnection.py

index 06be36177dae93c6880a7fba13a082c2b10ebeee..1f76365fea50b7b51a8ca7473be62ccdcdeed8d8 100644 (file)
@@ -36,14 +36,14 @@ class aboutWindow(wx.Frame):
                self.addComponent('NumPy', 'Support library for faster math', 'BSD', 'http://www.numpy.org/')
                if platform.system() == "Windows":
                        self.addComponent('VideoCapture', 'Library for WebCam capture on windows', 'LGPLv2.1', 'http://videocapture.sourceforge.net/')
-                       self.addComponent('ffmpeg', 'Support for making timelaps video files', 'GPL', 'http://www.ffmpeg.org/')
+                       #self.addComponent('ffmpeg', 'Support for making timelaps video files', 'GPL', 'http://www.ffmpeg.org/')
                        self.addComponent('comtypes', 'Library to help with windows taskbar features on Windows 7', 'MIT', 'http://starship.python.net/crew/theller/comtypes/')
                        self.addComponent('EjectMedia', 'Utility to safe-remove SD cards', 'Freeware', 'http://www.uwe-sieber.de/english.html')
                self.addComponent('Pymclevel', 'Python library for reading Minecraft levels.', 'ISC', 'https://github.com/mcedit/pymclevel')
 
                #Translations done by:
                #Dutch: Charlotte Jansen
-               #German: Gregor Luetolf
+               #German: Gregor Luetolf, Lars Potter
                #Polish: Piotr Paczynski
                #French: Jeremie Francois
                #Spanish: Jose Gemez
diff --git a/Cura/util/drawingLoader/__init__.py b/Cura/util/drawingLoader/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/Cura/util/drawingLoader/drawing.py b/Cura/util/drawingLoader/drawing.py
deleted file mode 100644 (file)
index 68a952e..0000000
+++ /dev/null
@@ -1,276 +0,0 @@
-__copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
-
-import math
-import numpy
-
-class Node(object):
-       LINE = 0
-       ARC = 1
-       CURVE = 2
-
-       def __init__(self, type, position):
-               self.type = type
-               self.position = position
-
-class LineNode(Node):
-       def __init__(self, position):
-               super(LineNode, self).__init__(Node.LINE, position)
-
-class ArcNode(Node):
-       def __init__(self, position, rotation, radius, large, sweep):
-               super(ArcNode, self).__init__(Node.ARC, position)
-               self.rotation = rotation
-               self.radius = radius
-               self.large = large
-               self.sweep = sweep
-
-class Path(object):
-       def __init__(self, x, y, matrix=numpy.matrix(numpy.identity(3, numpy.float64))):
-               self._matrix = matrix
-               self._relMatrix = numpy.matrix([[matrix[0,0],matrix[1,0]],[matrix[0,1],matrix[1,1]]], numpy.float64)
-               self._startPoint = self._m(complex(x, y))
-               self._nodes = []
-               self._isClosed = False
-
-       def addLineTo(self, x, y):
-               self._nodes.append(LineNode(self._m(complex(x, y))))
-
-       def addArcTo(self, x, y, rotation, rx, ry, large, sweep):
-               self._nodes.append(ArcNode(self._m(complex(x, y)), rotation, self._r(complex(rx, ry)), large, sweep))
-
-       def addCurveTo(self, x, y, cp1x, cp1y, cp2x, cp2y):
-               node = Node(Node.CURVE, self._m(complex(x, y)))
-               node.cp1 = self._m(complex(cp1x, cp1y))
-               node.cp2 = self._m(complex(cp2x, cp2y))
-               self._nodes.append(node)
-
-       def isClosed(self):
-               return self._isClosed
-
-       def closePath(self):
-               if abs(self._nodes[-1].position - self._startPoint) > 0.01:
-                       self._nodes.append(Node(Node.LINE, self._startPoint))
-               self._isClosed = True
-
-       def getArcInfo(self, node):
-               p1 = self._startPoint
-               if self._nodes[0] != node:
-                       p1 = self._nodes[self._nodes.index(node) - 1].position
-
-               p2 = node.position
-               if abs(p1 - p2) < 0.0001:
-                       return p1, 0.0, math.pi, complex(0.0, 0.0)
-               rot = math.radians(node.rotation)
-               r = node.radius
-
-               #http://www.w3.org/TR/SVG/implnote.html#ArcConversionEndpointToCenter
-               diff = (p1 - p2) / 2
-               p1alt = diff #TODO: apply rot
-               p2alt = -diff #TODO: apply rot
-               rx2 = r.real*r.real
-               ry2 = r.imag*r.imag
-               x1alt2 = p1alt.real*p1alt.real
-               y1alt2 = p1alt.imag*p1alt.imag
-
-               f = x1alt2 / rx2 + y1alt2 / ry2
-               if f >= 1.0:
-                       r *= math.sqrt(f+0.000001)
-                       rx2 = r.real*r.real
-                       ry2 = r.imag*r.imag
-
-               if rx2*y1alt2+ry2*x1alt2 == 0.0:
-                       f = 0
-               else:
-                       f = math.sqrt((rx2*ry2 - rx2*y1alt2 - ry2*x1alt2) / (rx2*y1alt2+ry2*x1alt2))
-               if node.large == node.sweep:
-                       f = -f
-               cAlt = f * complex(r.real*p1alt.imag/r.imag, -r.imag*p1alt.real/r.real)
-
-               c = cAlt + (p1 + p2) / 2 #TODO: apply rot
-
-               a1 = math.atan2((p1alt.imag - cAlt.imag) / r.imag, (p1alt.real - cAlt.real) / r.real)
-               a2 = math.atan2((p2alt.imag - cAlt.imag) / r.imag, (p2alt.real - cAlt.real) / r.real)
-
-               large = abs(a2 - a1) > math.pi
-               if large != node.large:
-                       if a1 < a2:
-                               a1 += math.pi * 2
-                       else:
-                               a2 += math.pi * 2
-
-               return c, a1, a2, r
-
-       def getPoints(self, accuracy = 1.0):
-               pointList = [(self._startPoint, -1)]
-               p1 = self._startPoint
-               idx = -1
-               for node in self._nodes:
-                       idx += 1
-                       if node.type == Node.LINE:
-                               p1 = node.position
-                               pointList.append((p1, idx))
-                       elif node.type == Node.ARC:
-                               p2 = node.position
-                               c, a1, a2, r = self.getArcInfo(node)
-
-                               pCenter = c + complex(math.cos(a1 + 0.5*(a2-a1)) * r.real, math.sin(a1 + 0.5*(a2-a1)) * r.imag)
-                               dist = abs(pCenter - p1) + abs(pCenter - p2)
-                               segments = int(dist / accuracy) + 1
-                               for n in xrange(1, segments):
-                                       p = c + complex(math.cos(a1 + n*(a2-a1)/segments) * r.real, math.sin(a1 + n*(a2-a1)/segments) * r.imag)
-                                       pointList.append((p, idx))
-
-                               pointList.append((p2, idx))
-                               p1 = p2
-                       elif node.type == Node.CURVE:
-                               p2 = node.position
-                               cp1 = node.cp1
-                               cp2 = node.cp2
-
-                               pCenter = p1*0.5*0.5*0.5 + cp1*3.0*0.5*0.5*0.5 + cp2*3.0*0.5*0.5*0.5 + p2*0.5*0.5*0.5
-                               dist = abs(pCenter - p1) + abs(pCenter - p2)
-                               segments = int(dist / accuracy) + 1
-                               for n in xrange(1, segments):
-                                       f = n / float(segments)
-                                       g = 1.0-f
-                                       point = p1*g*g*g + cp1*3.0*g*g*f + cp2*3.0*g*f*f + p2*f*f*f
-                                       pointList.append((point, idx))
-
-                               pointList.append((p2, idx))
-                               p1 = p2
-
-               return pointList
-
-       #getSVGPath returns an SVG path string. Ths path string is not perfect when matrix transformations are involved.
-       def getSVGPath(self):
-               p0 = self._startPoint
-               ret = 'M %f %f ' % (p0.real, p0.imag)
-               for node in self._nodes:
-                       if node.type == Node.LINE:
-                               p0 = node.position
-                               ret += 'L %f %f' % (p0.real, p0.imag)
-                       elif node.type == Node.ARC:
-                               p0 = node.position
-                               radius = node.radius
-                               ret += 'A %f %f 0 %d %d %f %f' % (radius.real, radius.imag, 1 if node.large else 0, 1 if node.sweep else 0, p0.real, p0.imag)
-                       elif node.type == Node.CURVE:
-                               p0 = node.position
-                               cp1 = node.cp1
-                               cp2 = node.cp2
-                               ret += 'C %f %f %f %f %f %f' % (cp1.real, cp1.imag, cp2.real, cp2.imag, p0.real, p0.imag)
-
-               return ret
-
-       def getPathString(self):
-               ret = '%f %f' % (self._startPoint.real, self._startPoint.imag)
-               for node in self._nodes:
-                       if node.type == Node.LINE:
-                               ret += '|L %f %f' % (node.position.real, node.position.imag)
-                       elif node.type == Node.ARC:
-                               ret += '|A %f %f %f %f %d %d' % (node.position.real, node.position.imag, node.radius.real, node.radius.imag, 1 if node.large else 0, 1 if node.sweep else 0)
-                       elif node.type == Node.CURVE:
-                               ret += '|C %f %f %f %f %f %f' % (node.position.real, node.position.imag, node.cp1.real, node.cp1.imag, node.cp2.real, node.cp2.imag)
-               return ret
-
-       def _m(self, p):
-               tmp = numpy.matrix([p.real, p.imag, 1], numpy.float64) * self._matrix
-               return complex(tmp[0,0], tmp[0,1])
-
-       def _r(self, p):
-               tmp = numpy.matrix([p.real, p.imag], numpy.float64) * self._relMatrix
-               return complex(tmp[0,0], tmp[0,1])
-
-class Drawing(object):
-       def __init__(self):
-               self.paths = []
-
-       def addPath(self, x, y, matrix=numpy.matrix(numpy.identity(3, numpy.float64))):
-               p = Path(x, y, matrix)
-               self.paths.append(p)
-               return p
-
-       def _postProcessPaths(self):
-               for path1 in self.paths:
-                       if not path1.isClosed() and len(path1._nodes) > 0:
-                               for path2 in self.paths:
-                                       if path1 != path2 and not path2.isClosed():
-                                               if abs(path1._nodes[-1].position - path2._startPoint) < 0.001:
-                                                       path1._nodes += path2._nodes
-                                                       path2._nodes = []
-
-               cleanList = []
-               for path in self.paths:
-                       if len(path._nodes) < 1:
-                               cleanList.append(path)
-               for path in cleanList:
-                       self.paths.remove(path)
-
-               for path in self.paths:
-                       if not path.isClosed():
-                               if abs(path._nodes[-1].position - path._startPoint) < 0.001:
-                                       path._isClosed = True
-                       if path.isClosed() and len(path._nodes) == 2 and path._nodes[0].type == Node.ARC and path._nodes[1].type == Node.ARC:
-                               if abs(path._nodes[0].radius - path._nodes[1].radius) < 0.001:
-                                       pass
-                                       #path._nodes = []
-
-       def dumpToFile(self, file):
-               file.write("%d\n" % (len(self.paths)))
-               for path in self.paths:
-                       file.write("%s\n" % (path.getPathString()))
-
-       def readFromFile(self, file):
-               self.paths = []
-               pathCount = int(file.readline())
-               for n in xrange(0, pathCount):
-                       line = map(str.split, file.readline().strip().split('|'))
-                       path = Path(float(line[0][0]), float(line[0][1]))
-                       for item in line[1:]:
-                               if item[0] == 'L':
-                                       path.addLineTo(float(item[1]), float(item[2]))
-                               elif item[0] == 'A':
-                                       path.addArcTo(float(item[1]), float(item[2]), 0, float(item[3]), float(item[4]), int(item[5]) != 0, int(item[6]) != 0)
-                               elif item[0] == 'C':
-                                       path.addCurveTo(float(item[1]), float(item[2]), float(item[3]), float(item[4]), float(item[5]), float(item[6]))
-                       self.paths.append(path)
-               self._postProcessPaths()
-
-       def saveAsHtml(self, filename):
-               f = open(filename, "w")
-
-               posMax = complex(-1000, -1000)
-               posMin = complex( 1000,  1000)
-               for path in self.paths:
-                       points = path.getPoints()
-                       for p in points:
-                               if p.real > posMax.real:
-                                       posMax = complex(p.real, posMax.imag)
-                               if p.imag > posMax.imag:
-                                       posMax = complex(posMax.real, p.imag)
-                               if p.real < posMin.real:
-                                       posMin = complex(p.real, posMin.imag)
-                               if p.imag < posMin.imag:
-                                       posMin = complex(posMin.real, p.imag)
-
-               f.write("<!DOCTYPE html><html><body>\n")
-               f.write("<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" style='width:%dpx;height:%dpx'>\n" % ((posMax - posMin).real, (posMax - posMin).imag))
-               f.write("<g fill-rule='evenodd' style=\"fill: gray; stroke:black;stroke-width:2\">\n")
-               f.write("<path d=\"")
-               for path in self.paths:
-                       points = path.getPoints()
-                       f.write("M %f %f " % (points[0].real - posMin.real, points[0].imag - posMin.imag))
-                       for point in points[1:]:
-                               f.write("L %f %f " % (point.real - posMin.real, point.imag - posMin.imag))
-               f.write("\"/>")
-               f.write("</g>\n")
-
-               f.write("<g style=\"fill: none; stroke:red;stroke-width:1\">\n")
-               f.write("<path d=\"")
-               for path in self.paths:
-                       f.write(path.getSVGPath())
-               f.write("\"/>")
-               f.write("</g>\n")
-
-               f.write("</svg>\n")
-               f.write("</body></html>")
-               f.close()
diff --git a/Cura/util/drawingLoader/dxf.py b/Cura/util/drawingLoader/dxf.py
deleted file mode 100644 (file)
index 8e2a789..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-__copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
-
-import math
-import re
-import sys
-import numpy
-from xml.etree import ElementTree
-
-from Cura.util.drawingLoader import drawing
-
-class DXF(drawing.Drawing):
-       def __init__(self, filename):
-               super(DXF, self).__init__()
-               self._lastLine = None
-               self._polyLine = None
-
-               entityType = 'NONE'
-               sectionName = 'NONE'
-               activeObject = None
-               f = open(filename, "r")
-               while True:
-                       groupCode = f.readline().strip()
-                       if groupCode == '':
-                               break
-                       groupCode = int(groupCode)
-                       value = f.readline().strip()
-                       if groupCode == 0:
-                               if entityType == 'SECTION':
-                                       sectionName = activeObject[2][0]
-                               elif entityType == 'ENDSEC':
-                                       sectionName = 'NONE'
-                               elif sectionName == 'ENTITIES':
-                                       self._checkForNewPath(entityType, activeObject)
-                               elif activeObject is not None:
-                                       pass
-                                       #print sectionName, entityType, activeObject
-                               entityType = value
-                               activeObject = {}
-                       else:
-                               if groupCode in activeObject:
-                                       activeObject[groupCode].append(value)
-                               else:
-                                       activeObject[groupCode] = [value]
-               if sectionName == 'ENTITIES':
-                       self._checkForNewPath(entityType, activeObject)
-               f.close()
-
-               self._postProcessPaths()
-
-       def _checkForNewPath(self, type, obj):
-               if type == 'LINE':
-                       if self._lastLine is not None and self._lastLinePoint == complex(float(obj[10][0]), float(obj[20][0])):
-                               self._lastLine.addLineTo(float(obj[11][0]), float(obj[21][0]))
-                       else:
-                               p = self.addPath(float(obj[10][0]), float(obj[20][0]))
-                               p.addLineTo(float(obj[11][0]), float(obj[21][0]))
-                               self._lastLine = p
-                       self._lastLinePoint = complex(float(obj[11][0]), float(obj[21][0]))
-               elif type == 'POLYLINE':
-                       self._polyLine = None
-               elif type == 'VERTEX':
-                       if self._polyLine is None:
-                               self._polyLine = self.addPath(float(obj[10][0]), float(obj[20][0]))
-                       else:
-                               self._polyLine.addLineTo(float(obj[10][0]), float(obj[20][0]))
-               elif type == 'LWPOLYLINE':
-                       p = self.addPath(float(obj[10][0]), float(obj[20][0]))
-                       for n in xrange(1, len(obj[10])):
-                               p.addLineTo(float(obj[10][n]), float(obj[20][n]))
-                       self._lastLine = p
-               elif type == 'SPLINE':
-                       p = self.addPath(float(obj[10][0]), float(obj[20][0]))
-                       for n in xrange(1, len(obj[10])):
-                               p.addLineTo(float(obj[10][n]), float(obj[20][n]))
-                       self._lastLine = p
-               else:
-                       print 'type=%s' % type
-                       for k in obj.keys():
-                               print k, obj[k]
-
-if __name__ == '__main__':
-       for n in xrange(1, len(sys.argv)):
-               print 'File: %s' % (sys.argv[n])
-               dxf = DXF(sys.argv[n])
-
-       dxf.saveAsHtml("test_export.html")
-
diff --git a/Cura/util/drawingLoader/svg.py b/Cura/util/drawingLoader/svg.py
deleted file mode 100644 (file)
index c9c9187..0000000
+++ /dev/null
@@ -1,388 +0,0 @@
-__copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
-
-import math
-import re
-import sys
-import numpy
-from xml.etree import ElementTree
-
-from Cura.util.drawingLoader import drawing
-
-def applyTransformString(matrix, transform):
-       while transform != '':
-               if transform[0] == ',':
-                       transform = transform[1:].strip()
-               s = transform.find('(')
-               e = transform.find(')')
-               if s < 0 or e < 0:
-                       print 'Unknown transform: %s' % (transform)
-                       return matrix
-               tag = transform[:s]
-               data = map(float, re.split('[ \t,]+', transform[s+1:e].strip()))
-               if tag == 'matrix' and len(data) == 6:
-                       matrix = numpy.matrix([[data[0],data[1],0],[data[2],data[3],0],[data[4],data[5],1]], numpy.float64) * matrix
-               elif tag == 'translate' and len(data) == 1:
-                       matrix = numpy.matrix([[1,0,data[0]],[0,1,0],[0,0,1]], numpy.float64) * matrix
-               elif tag == 'translate' and len(data) == 2:
-                       matrix = numpy.matrix([[1,0,0],[0,1,0],[data[0],data[1],1]], numpy.float64) * matrix
-               elif tag == 'scale' and len(data) == 1:
-                       matrix = numpy.matrix([[data[0],0,0],[0,data[0],0],[0,0,1]], numpy.float64) * matrix
-               elif tag == 'scale' and len(data) == 2:
-                       matrix = numpy.matrix([[data[0],0,0],[0,data[1],0],[0,0,1]], numpy.float64) * matrix
-               elif tag == 'rotate' and len(data) == 1:
-                       r = math.radians(data[0])
-                       matrix = numpy.matrix([[math.cos(r),math.sin(r),0],[-math.sin(r),math.cos(r),0],[0,0,1]], numpy.float64) * matrix
-               elif tag == 'rotate' and len(data) == 3:
-                       matrix = numpy.matrix([[1,0,0],[0,1,0],[data[1],data[2],1]], numpy.float64) * matrix
-                       r = math.radians(data[0])
-                       matrix = numpy.matrix([[math.cos(r),math.sin(r),0],[-math.sin(r),math.cos(r),0],[0,0,1]], numpy.float64) * matrix
-                       matrix = numpy.matrix([[1,0,0],[0,1,0],[-data[1],-data[2],1]], numpy.float64) * matrix
-               elif tag == 'skewX' and len(data) == 1:
-                       matrix = numpy.matrix([[1,0,0],[math.tan(data[0]),1,0],[0,0,1]], numpy.float64) * matrix
-               elif tag == 'skewY' and len(data) == 1:
-                       matrix = numpy.matrix([[1,math.tan(data[0]),0],[0,1,0],[0,0,1]], numpy.float64) * matrix
-               else:
-                       print 'Unknown transform: %s' % (transform)
-                       return matrix
-               transform = transform[e+1:].strip()
-       return matrix
-
-def toFloat(f):
-       f = re.search('^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?', f).group(0)
-       return float(f)
-
-class SVG(drawing.Drawing):
-       def __init__(self, filename):
-               super(SVG, self).__init__()
-               self.tagProcess = {}
-               self.tagProcess['rect'] = self._processRectTag
-               self.tagProcess['line'] = self._processLineTag
-               self.tagProcess['polyline'] = self._processPolylineTag
-               self.tagProcess['polygon'] = self._processPolygonTag
-               self.tagProcess['elipse'] = self._processPolygonTag
-               self.tagProcess['circle'] = self._processCircleTag
-               self.tagProcess['ellipse'] = self._processEllipseTag
-               self.tagProcess['path'] = self._processPathTag
-               self.tagProcess['use'] = self._processUseTag
-               self.tagProcess['g'] = self._processGTag
-               self.tagProcess['a'] = self._processGTag
-               self.tagProcess['svg'] = self._processGTag
-               self.tagProcess['text'] = None #No text implementation yet
-               self.tagProcess['image'] = None
-               self.tagProcess['metadata'] = None
-               self.tagProcess['defs'] = None
-               self.tagProcess['style'] = None
-               self.tagProcess['marker'] = None
-               self.tagProcess['desc'] = None
-               self.tagProcess['filter'] = None
-               self.tagProcess['linearGradient'] = None
-               self.tagProcess['radialGradient'] = None
-               self.tagProcess['pattern'] = None
-               self.tagProcess['title'] = None
-               self.tagProcess['animate'] = None
-               self.tagProcess['animateColor'] = None
-               self.tagProcess['animateTransform'] = None
-               self.tagProcess['set'] = None
-               self.tagProcess['script'] = None
-
-               #From Inkscape
-               self.tagProcess['namedview'] = None
-               #From w3c testsuite
-               self.tagProcess['SVGTestCase'] = None
-
-               f = open(filename, "r")
-               self._xml = ElementTree.parse(f)
-               self._recursiveCount = 0
-               matrix = numpy.matrix(numpy.identity(3, numpy.float64))
-               matrix = applyTransformString(matrix, "scale(%f)" % (25.4/90.0)) #Per default convert with 90 dpi
-               self._processGTag(self._xml.getroot(), matrix)
-               self._xml = None
-               f.close()
-
-               self._postProcessPaths()
-
-       def _processGTag(self, tag, baseMatrix):
-               for e in tag:
-                       if e.get('transform') is None:
-                               matrix = baseMatrix
-                       else:
-                               matrix = applyTransformString(baseMatrix, e.get('transform'))
-                       tagName = e.tag[e.tag.find('}')+1:]
-                       if not tagName in self.tagProcess:
-                               print 'unknown tag: %s' % (tagName)
-                       elif self.tagProcess[tagName] is not None:
-                               self.tagProcess[tagName](e, matrix)
-
-       def _processUseTag(self, tag, baseMatrix):
-               if self._recursiveCount > 16:
-                       return
-               self._recursiveCount += 1
-               id = tag.get('{http://www.w3.org/1999/xlink}href')
-               if id[0] == '#':
-                       for e in self._xml.findall(".//*[@id='%s']" % (id[1:])):
-                               if e.get('transform') is None:
-                                       matrix = baseMatrix
-                               else:
-                                       matrix = applyTransformString(baseMatrix, e.get('transform'))
-                               tagName = e.tag[e.tag.find('}')+1:]
-                               if not tagName in self.tagProcess:
-                                       print 'unknown tag: %s' % (tagName)
-                               elif self.tagProcess[tagName] is not None:
-                                       self.tagProcess[tagName](e, matrix)
-               self._recursiveCount -= 1
-
-       def _processLineTag(self, tag, matrix):
-               x1 = toFloat(tag.get('x1', '0'))
-               y1 = toFloat(tag.get('y1', '0'))
-               x2 = toFloat(tag.get('x2', '0'))
-               y2 = toFloat(tag.get('y2', '0'))
-               p = self.addPath(x1, y1, matrix)
-               p.addLineTo(x2, y2)
-
-       def _processPolylineTag(self, tag, matrix):
-               values = map(toFloat, re.split('[, \t]+', tag.get('points', '').strip()))
-               p = self.addPath(values[0], values[1], matrix)
-               for n in xrange(2, len(values)-1, 2):
-                       p.addLineTo(values[n], values[n+1])
-
-       def _processPolygonTag(self, tag, matrix):
-               values = map(toFloat, re.split('[, \t]+', tag.get('points', '').strip()))
-               p = self.addPath(values[0], values[1], matrix)
-               for n in xrange(2, len(values)-1, 2):
-                       p.addLineTo(values[n], values[n+1])
-               p.closePath()
-
-       def _processCircleTag(self, tag, matrix):
-               cx = toFloat(tag.get('cx', '0'))
-               cy = toFloat(tag.get('cy', '0'))
-               r = toFloat(tag.get('r', '0'))
-               p = self.addPath(cx-r, cy, matrix)
-               p.addArcTo(cx+r, cy, 0, r, r, False, False)
-               p.addArcTo(cx-r, cy, 0, r, r, False, False)
-
-       def _processEllipseTag(self, tag, matrix):
-               cx = toFloat(tag.get('cx', '0'))
-               cy = toFloat(tag.get('cy', '0'))
-               rx = toFloat(tag.get('rx', '0'))
-               ry = toFloat(tag.get('rx', '0'))
-               p = self.addPath(cx-rx, cy, matrix)
-               p.addArcTo(cx+rx, cy, 0, rx, ry, False, False)
-               p.addArcTo(cx-rx, cy, 0, rx, ry, False, False)
-
-       def _processRectTag(self, tag, matrix):
-               x = toFloat(tag.get('x', '0'))
-               y = toFloat(tag.get('y', '0'))
-               width = toFloat(tag.get('width', '0'))
-               height = toFloat(tag.get('height', '0'))
-               if width <= 0 or height <= 0:
-                       return
-               rx = tag.get('rx')
-               ry = tag.get('ry')
-               if rx is not None or ry is not None:
-                       if ry is None:
-                               ry = rx
-                       if rx is None:
-                               rx = ry
-                       rx = float(rx)
-                       ry = float(ry)
-                       if rx > width / 2:
-                               rx = width / 2
-                       if ry > height / 2:
-                               ry = height / 2
-               else:
-                       rx = 0.0
-                       ry = 0.0
-
-               if rx > 0 and ry > 0:
-                       p = self.addPath(x+width-rx, y, matrix)
-                       p.addArcTo(x+width,y+ry, 0, rx, ry, False, True)
-                       p.addLineTo(x+width, y+height-ry)
-                       p.addArcTo(x+width-rx,y+height, 0, rx, ry, False, True)
-                       p.addLineTo(x+rx, y+height)
-                       p.addArcTo(x,y+height-ry, 0, rx, ry, False, True)
-                       p.addLineTo(x, y+ry)
-                       p.addArcTo(x+rx,y, 0, rx, ry, False, True)
-                       p.closePath()
-               else:
-                       p = self.addPath(x, y, matrix)
-                       p.addLineTo(x,y+height)
-                       p.addLineTo(x+width,y+height)
-                       p.addLineTo(x+width,y)
-                       p.closePath()
-
-       def _processPathTag(self, tag, matrix):
-               pathString = tag.get('d', '').replace(',', ' ')
-               x = 0
-               y = 0
-               c2x = 0
-               c2y = 0
-               path = None
-               for command in re.findall('[a-df-zA-DF-Z][^a-df-zA-DF-Z]*', pathString):
-                       params = re.split(' +', command[1:].strip())
-                       if len(params) > 0 and params[0] == '':
-                               params = params[1:]
-                       if len(params) > 0 and params[-1] == '':
-                               params = params[:-1]
-                       params = map(toFloat, params)
-                       command = command[0]
-
-                       if command == 'm':
-                               x += params[0]
-                               y += params[1]
-                               path = self.addPath(x, y, matrix)
-                               params = params[2:]
-                               while len(params) > 1:
-                                       x += params[0]
-                                       y += params[1]
-                                       params = params[2:]
-                                       path.addLineTo(x, y)
-                               c2x, c2y = x, y
-                       elif command == 'M':
-                               x = params[0]
-                               y = params[1]
-                               path = self.addPath(x, y, matrix)
-                               params = params[2:]
-                               while len(params) > 1:
-                                       x = params[0]
-                                       y = params[1]
-                                       params = params[2:]
-                                       path.addLineTo(x, y)
-                               c2x, c2y = x, y
-                       elif command == 'l':
-                               while len(params) > 1:
-                                       x += params[0]
-                                       y += params[1]
-                                       params = params[2:]
-                                       path.addLineTo(x, y)
-                               c2x, c2y = x, y
-                       elif command == 'L':
-                               while len(params) > 1:
-                                       x = params[0]
-                                       y = params[1]
-                                       params = params[2:]
-                                       path.addLineTo(x, y)
-                               c2x, c2y = x, y
-                       elif command == 'h':
-                               x += params[0]
-                               path.addLineTo(x, y)
-                               c2x, c2y = x, y
-                       elif command == 'H':
-                               x = params[0]
-                               path.addLineTo(x, y)
-                               c2x, c2y = x, y
-                       elif command == 'v':
-                               y += params[0]
-                               path.addLineTo(x, y)
-                               c2x, c2y = x, y
-                       elif command == 'V':
-                               y = params[0]
-                               path.addLineTo(x, y)
-                               c2x, c2y = x, y
-                       elif command == 'a':
-                               while len(params) > 6:
-                                       x += params[5]
-                                       y += params[6]
-                                       path.addArcTo(x, y, params[2], params[0], params[1], params[3] > 0, params[4] > 0)
-                                       params = params[7:]
-                               c2x, c2y = x, y
-                       elif command == 'A':
-                               while len(params) > 6:
-                                       x = params[5]
-                                       y = params[6]
-                                       path.addArcTo(x, y, params[2], params[0], params[1], params[3] > 0, params[4] > 0)
-                                       params = params[7:]
-                               c2x, c2y = x, y
-                       elif command == 'c':
-                               while len(params) > 5:
-                                       c1x = x + params[0]
-                                       c1y = y + params[1]
-                                       c2x = x + params[2]
-                                       c2y = y + params[3]
-                                       x += params[4]
-                                       y += params[5]
-                                       path.addCurveTo(x, y, c1x, c1y, c2x, c2y)
-                                       params = params[6:]
-                       elif command == 'C':
-                               while len(params) > 5:
-                                       c1x = params[0]
-                                       c1y = params[1]
-                                       c2x = params[2]
-                                       c2y = params[3]
-                                       x = params[4]
-                                       y = params[5]
-                                       path.addCurveTo(x, y, c1x, c1y, c2x, c2y)
-                                       params = params[6:]
-                       elif command == 's':
-                               while len(params) > 3:
-                                       c1x = x - (c2x - x)
-                                       c1y = y - (c2y - y)
-                                       c2x = x + params[0]
-                                       c2y = y + params[1]
-                                       x += params[2]
-                                       y += params[3]
-                                       path.addCurveTo(x, y, c1x, c1y, c2x, c2y)
-                                       params = params[4:]
-                       elif command == 'S':
-                               while len(params) > 3:
-                                       c1x = x - (c2x - x)
-                                       c1y = y - (c2y - y)
-                                       c2x = params[0]
-                                       c2y = params[1]
-                                       x = params[2]
-                                       y = params[3]
-                                       path.addCurveTo(x, y, c1x, c1y, c2x, c2y)
-                                       params = params[4:]
-                       elif command == 'q':
-                               while len(params) > 3:
-                                       c1x = x + params[0]
-                                       c1y = y + params[1]
-                                       c2x = c1x
-                                       c2y = c1y
-                                       x += params[2]
-                                       y += params[3]
-                                       path.addCurveTo(x, y, c1x, c1y, c2x, c2y)
-                                       params = params[4:]
-                       elif command == 'Q':
-                               while len(params) > 3:
-                                       c1x = params[0]
-                                       c1y = params[1]
-                                       c2x = c1x
-                                       c2y = c1y
-                                       x = params[2]
-                                       y = params[3]
-                                       path.addCurveTo(x, y, c1x, c1y, c2x, c2y)
-                                       params = params[4:]
-                       elif command == 't':
-                               while len(params) > 1:
-                                       c1x = x - (c2x - x)
-                                       c1y = y - (c2y - y)
-                                       c2x = c1x
-                                       c2y = c1y
-                                       x += params[0]
-                                       y += params[1]
-                                       path.addCurveTo(x, y, c1x, c1y, c2x, c2y)
-                                       params = params[2:]
-                       elif command == 'T':
-                               while len(params) > 1:
-                                       c1x = x - (c2x - x)
-                                       c1y = y - (c2y - y)
-                                       c2x = c1x
-                                       c2y = c1y
-                                       x = params[0]
-                                       y = params[1]
-                                       path.addCurveTo(x, y, c1x, c1y, c2x, c2y)
-                                       params = params[2:]
-                       elif command == 'z' or command == 'Z':
-                               path.closePath()
-                               x = path._startPoint.real
-                               y = path._startPoint.imag
-                       else:
-                               print 'Unknown path command:', command, params
-
-
-if __name__ == '__main__':
-       for n in xrange(1, len(sys.argv)):
-               print 'File: %s' % (sys.argv[n])
-               svg = SVG(sys.argv[n])
-
-       svg.saveAsHtml("test_export.html")
index 0182a7ec3150ad928076c20ce34c9375f4ef61f9..9c309ee5d91618b66537a1f0b1bea8a249c4c556 100644 (file)
@@ -1,3 +1,7 @@
+"""
+Doodle3D printer connection. Auto-detects any Doodle3D boxes on the local network, and finds if they have a printer connected.
+This connection can then be used to send GCode to the printer.
+"""
 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
 
 import threading
index 42a7834f43d6919577cb23a3d7913819c4bee4cd..943cc4997f12d1c5b3c2e16cec2b7b02c35dabf3 100644 (file)
@@ -1,3 +1,7 @@
+"""
+The dummy connection is a virtual printer connection which simulates the connection to a printer without doing anything.
+This is only enabled when you have a development version. And is used for debugging.
+"""
 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
 
 import threading
index 60fe501cf0887de12472e188ace70d9e1c2e6b37..c4e6f33a01e3cd2ef6370a5344d1eb266f921657 100644 (file)
@@ -1,3 +1,7 @@
+"""
+Base of all printer connections. A printer connection is a way a connection can be made with a printer.
+The connections are based on a group, where each group can have 1 or more connections.
+"""
 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
 
 import traceback
@@ -24,13 +28,14 @@ class printerConnectionGroup(object):
        def __repr__(self):
                return '%s %d' % (self._name, self.getPriority())
 
-#Base class for different printer connection implementations.
-# A printer connection can connect to printers in different ways, trough network, USB or carrier pigeons.
-# Each printer connection has different capabilities that you can query with the "has" functions.
-# Each printer connection has a state that you can query with the "is" functions.
-# Each printer connection has callback objects that receive status updates from the printer when information changes.
-
 class printerConnectionBase(object):
+       """
+       Base class for different printer connection implementations.
+               A printer connection can connect to printers in different ways, trough network, USB or carrier pigeons.
+               Each printer connection has different capabilities that you can query with the "has" functions.
+               Each printer connection has a state that you can query with the "is" functions.
+               Each printer connection has callback objects that receive status updates from the printer when information changes.
+       """
        def __init__(self, name):
                self._callbackList = []
                self._name = name
index c1dd2081ff43936b356fa6c67ae39aef2e5fe419..2322742cfc075662cccd29331e6f9d209f67833d 100644 (file)
@@ -1,3 +1,10 @@
+"""
+The printer connection manager keeps track of all the possible printer connections that can be made.
+It sorts them by priority and gives easy access to the first available connection type.
+
+This is used by the print/save button to give access to the first available print connection.
+As well as listing all printers under the right mouse button.
+"""
 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
 
 from Cura.util import profile
index 0777a570fee776e03671e7e8928de215cee3a01e..c02734260b36add69a87ececd733630d79101fc5 100644 (file)
@@ -1,3 +1,7 @@
+"""
+The serial/USB printer connection. Uses a 2nd python process to connect to the printer so we never
+have locking problems where other threads in python can block the USB printing.
+"""
 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
 
 import threading