chiark / gitweb /
More documentation.
authordaid <daid303@gmail.com>
Fri, 14 Feb 2014 09:17:34 +0000 (10:17 +0100)
committerdaid <daid303@gmail.com>
Fri, 14 Feb 2014 09:17:34 +0000 (10:17 +0100)
14 files changed:
Cura/serialCommunication.py
Cura/util/gcodeGenerator.py
Cura/util/gcodeInterpreter.py
Cura/util/machineCom.py
Cura/util/meshLoaders/dae.py
Cura/util/objectScene.py
Cura/util/pluginInfo.py
Cura/util/printableObject.py
Cura/util/printerConnection/doodle3dConnect.py
Cura/util/printerConnection/dummyConnection.py
Cura/util/printerConnection/printerConnectionManager.py
Cura/util/profile.py
Cura/util/sliceEngine.py
Cura/util/youmagine.py

index 7a2d91ea2e9da8e266f3bbea85ec445e4468e611..7447f83afd163e87389f768a6d1d7e7a1f3ce711 100644 (file)
@@ -15,6 +15,10 @@ import json
 from Cura.util import machineCom
 
 class serialComm(object):
+       """
+       The serialComm class is the interface class which handles the communication between stdin/stdout and the machineCom class.
+       This interface class is used to run the (USB) serial communication in a different process then the GUI.
+       """
        def __init__(self, portName):
                self._comm = None
                self._gcodeList = []
index cb6ed709761abd2a18333a431fed14a6b77a3d2e..47b473c4b4a5ce362f7aca4d1274619c9ae44d95 100644 (file)
@@ -9,6 +9,10 @@ import math
 from Cura.util import profile
 
 class gcodeGenerator(object):
+       """
+       Generates a simple set of GCode commands for RepRap GCode firmware.
+       Use the add* commands to build the GCode, and then use the list function to retrieve the resulting gcode.
+       """
        def __init__(self):
                self._feedPrint = profile.getProfileSettingFloat('print_speed') * 60
                self._feedTravel = profile.getProfileSettingFloat('travel_speed') * 60
index 4bf13a7a281427b7238661fda3b1706cfc79ab76..45f65c0f4f88a0e21160a58c71e6c44412e4594d 100644 (file)
@@ -15,6 +15,9 @@ import cStringIO as StringIO
 from Cura.util import profile
 
 def gcodePath(newType, pathType, layerThickness, startPoint):
+       """
+       Build a gcodePath object. This used to be objects, however, this code is timing sensitive and dictionaries proved to be faster.
+       """
        return {'type': newType,
                        'pathType': pathType,
                        'layerThickness': layerThickness,
@@ -22,6 +25,10 @@ def gcodePath(newType, pathType, layerThickness, startPoint):
                        'extrusion': [0.0]}
 
 class gcode(object):
+       """
+       The heavy lifting GCode parser. This is most likely the hardest working python code in Cura.
+       It parses a GCode file and stores the result in layers where each layer as paths that describe the GCode.
+       """
        def __init__(self):
                self.regMatch = {}
                self.layerList = None
index dc3430b4c849abffd8c3048c6f3e64d2fd09e678..b0cac8bb8a5b75895da6a47dc5f07747d38a89f0 100644 (file)
@@ -1,6 +1,6 @@
 """
-MachineCom handles communication with GCode based printers trough serial ports.
-For actual printing of objects this module is used from Cura.serialCommunication and ran in a seperate process.
+MachineCom handles communication with GCode based printers trough (USB) serial ports.
+For actual printing of objects this module is used from Cura.serialCommunication and ran in a separate process.
 """
 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
 
@@ -29,6 +29,11 @@ except:
        pass
 
 def serialList(forAutoDetect=False):
+       """
+               Retrieve a list of serial ports found in the system.
+       :param forAutoDetect: if true then only the USB serial ports are listed. Else all ports are listed.
+       :return: A list of strings where each string is a serial port.
+       """
        baselist=[]
        if platform.system() == "Windows":
                try:
@@ -54,18 +59,11 @@ def serialList(forAutoDetect=False):
                baselist.append('VIRTUAL')
        return baselist
 
-def machineIsConnected():
-       #UltiGCode is designed for SD-Card printing, so never auto-detect the serial port.
-       port = profile.getMachineSetting('serial_port')
-       if port == 'AUTO':
-               if profile.getMachineSetting('gcode_flavor') == 'UltiGCode':
-                       return False
-               return len(serialList(True)) > 0
-       if platform.system() == "Windows":
-               return port in serialList()
-       return os.path.isfile(port)
-
 def baudrateList():
+       """
+       :return: a list of integers containing all possible baudrates at which we can communicate.
+                       Used for auto-baudrate detection as well as manual baudrate selection.
+       """
        ret = [250000, 230400, 115200, 57600, 38400, 19200, 9600]
        if profile.getMachineSetting('serial_baud_auto') != '':
                prev = int(profile.getMachineSetting('serial_baud_auto'))
@@ -75,6 +73,10 @@ def baudrateList():
        return ret
 
 class VirtualPrinter():
+       """
+       A virtual printer class used for debugging. Acts as a serial.Serial class, but without connecting to any port.
+       Only available when running the development version of Cura.
+       """
        def __init__(self):
                self.readList = ['start\n', 'Marlin: Virtual Marlin!\n', '\x80\n']
                self.temp = 0.0
@@ -127,6 +129,10 @@ class VirtualPrinter():
                self.readList = None
 
 class MachineComPrintCallback(object):
+       """
+       Base class for callbacks from the MachineCom class.
+       This class has all empty implementations and is attached to the MachineCom if no other callback object is attached.
+       """
        def mcLog(self, message):
                pass
        
@@ -146,6 +152,10 @@ class MachineComPrintCallback(object):
                pass
 
 class MachineCom(object):
+       """
+       Class for (USB) serial communication with 3D printers.
+       This class keeps track of if the connection is still live, can auto-detect serial ports and baudrates.
+       """
        STATE_NONE = 0
        STATE_OPEN_SERIAL = 1
        STATE_DETECT_SERIAL = 2
index 9dd0e91b8a431af5c29ea863b334c588059607be..428a8300f45dc5108a7077ad87ba62d7074dc660 100644 (file)
@@ -17,6 +17,12 @@ def loadScene(filename):
        return [loader.obj]
 
 class daeLoader(object):
+       """
+       COLLADA object loader. This class is a bit of a mess, COLLADA files are complex beasts, and this code has only been tweaked to accept
+       the COLLADA files exported from SketchUp.
+
+       Parts of this class can be cleaned up and improved by using more numpy.
+       """
        def __init__(self, filename):
                self.obj = printableObject.printableObject(filename)
                self.mesh = self.obj._addMesh()
index 01b535eed0a3a8e7b765e4f2d1d4255690f0f82a..1a3437c894421d69835c865aea38beec74066365 100644 (file)
@@ -12,11 +12,21 @@ from Cura.util import profile
 from Cura.util import polygon
 
 class _objectOrder(object):
+       """
+       Internal object used by the _objectOrderFinder to keep track of a possible order in which to print objects.
+       """
        def __init__(self, order, todo):
+               """
+               :param order:   List of indexes in which to print objects, ordered by printing order.
+               :param todo:    List of indexes which are not yet inserted into the order list.
+               """
                self.order = order
                self.todo = todo
 
 class _objectOrderFinder(object):
+       """
+       Internal object used by the Scene class to figure out in which order to print objects.
+       """
        def __init__(self, scene, leftToRight, frontToBack, gantryHeight):
                self._scene = scene
                self._objs = scene.objects()
@@ -91,6 +101,10 @@ class _objectOrderFinder(object):
                return polygon.polygonCollision(obj._boundaryHull + obj.getPosition(), addObj._headAreaHull + addObj.getPosition())
 
 class Scene(object):
+       """
+       The scene class keep track of an collection of objects on a build platform and their state.
+       It can figure out in which order to print them (if any) and if an object can be printed at all.
+       """
        def __init__(self):
                self._objectList = []
                self._sizeOffsets = numpy.array([0.0,0.0], numpy.float32)
index 0d71e136842230904381bc0acdc95bd9fc3919a9..7290c8bc31a6571669368c9c73825e1f718dfbd2 100644 (file)
@@ -18,6 +18,10 @@ from Cura.util import resources
 _pluginList = None
 
 class pluginInfo(object):
+       """
+       Plugin information object. Used to keep track of information about the available plugins in this installation of Cura.
+       Each plugin as meta-data associated with it which can be retrieved from this class.
+       """
        def __init__(self, dirname, filename):
                self._dirname = dirname
                self._filename = filename
index ff980aae6e2b4a0e82c51b9f50ac3b90bc4f941f..ce761325461054e957d139505da5caf8ace830df 100644 (file)
@@ -15,6 +15,13 @@ numpy.seterr(all='ignore')
 from Cura.util import polygon
 
 class printableObject(object):
+       """
+       A printable object is an object that can be printed and is on the build platform.
+       It contains 1 or more Meshes. Where more meshes are used for multi-extrusion.
+
+       Each object has a 3x3 transformation matrix to rotate/scale the object.
+       This object also keeps track of the 2D boundary polygon used for object collision in the objectScene class.
+       """
        def __init__(self, originFilename):
                self._originFilename = originFilename
                if originFilename is None:
@@ -290,6 +297,11 @@ class printableObject(object):
                return numpy.array(vertexList, numpy.float32), meshList
 
 class mesh(object):
+       """
+       A mesh is a list of 3D triangles build from vertexes. Each triangle has 3 vertexes.
+
+       A "VBO" can be associated with this object, which is used for rendering this object.
+       """
        def __init__(self, obj):
                self.vertexes = None
                self.vertexCount = 0
index 9c309ee5d91618b66537a1f0b1bea8a249c4c556..ec2f5534404e3d908e4676413ff5a75b496fdfa3 100644 (file)
@@ -13,6 +13,10 @@ import time
 from Cura.util.printerConnection import printerConnectionBase
 
 class doodle3dConnectionGroup(printerConnectionBase.printerConnectionGroup):
+       """
+       The Doodle3D connection group runs a thread to poll for Doodle3D boxes.
+       For each Doodle3D box it finds, it creates a Doodle3DConnect object.
+       """
        PRINTER_LIST_HOST = 'connect.doodle3d.com'
        PRINTER_LIST_PATH = '/api/list.php'
 
@@ -93,9 +97,11 @@ class doodle3dConnectionGroup(printerConnectionBase.printerConnectionGroup):
 
                return response
 
-#Class to connect and print files with the doodle3d.com wifi box
-# Auto-detects if the Doodle3D box is available with a printer
 class doodle3dConnect(printerConnectionBase.printerConnectionBase):
+       """
+       Class to connect and print files with the doodle3d.com wifi box
+       Auto-detects if the Doodle3D box is available with a printer and handles communication with the Doodle3D API
+       """
        def __init__(self, host, name, group):
                super(doodle3dConnect, self).__init__(name)
 
index 943cc4997f12d1c5b3c2e16cec2b7b02c35dabf3..17bebcdc5c5a21dbff1df159f0086cc197e08f7b 100644 (file)
@@ -13,6 +13,10 @@ import time
 from Cura.util.printerConnection import printerConnectionBase
 
 class dummyConnectionGroup(printerConnectionBase.printerConnectionGroup):
+       """
+       Group used for dummy conections. Always shows 2 dummy connections for debugging.
+       Has a very low priority so it does not prevent other connections from taking priority.
+       """
        def __init__(self):
                super(dummyConnectionGroup, self).__init__("Dummy")
                self._list = [dummyConnection("Dummy 1"), dummyConnection("Dummy 2")]
@@ -26,8 +30,10 @@ class dummyConnectionGroup(printerConnectionBase.printerConnectionGroup):
        def getPriority(self):
                return -100
 
-#Dummy printer class which is always
 class dummyConnection(printerConnectionBase.printerConnectionBase):
+       """
+       A dummy printer class to debug printer windows.
+       """
        def __init__(self, name):
                super(dummyConnection, self).__init__(name)
 
index 2322742cfc075662cccd29331e6f9d209f67833d..9fde1cbeda1cda55023226a3ebf76ef2c8122511 100644 (file)
@@ -14,6 +14,10 @@ from Cura.util.printerConnection import serialConnection
 from Cura.util.printerConnection import doodle3dConnect
 
 class PrinterConnectionManager(object):
+       """
+       The printer connection manager has one of each printer connection groups. Sorted on priority.
+       It can retrieve the first available connection as well as all available connections.
+       """
        def __init__(self):
                self._groupList = []
                if version.isDevVersion():
index db5381499e341b6a774c91af2434e24eb8053f1f..f563d6dc0aff638311793d904a62b4b024d09318 100644 (file)
@@ -39,15 +39,17 @@ settingsList = []
 _selectedMachineIndex = 0
 
 class setting(object):
-       #A setting object contains a configuration setting. These are globally accessible trough the quick access functions
-       # and trough the settingsDictionary function.
-       # Settings can be:
-       # * profile settings (settings that effect the slicing process and the print result)
-       # * preferences (settings that effect how cura works and acts)
-       # * machine settings (settings that relate to the physical configuration of your machine)
-       # * alterations (bad name copied from Skeinforge. These are the start/end code pieces)
-       # Settings have validators that check if the value is valid, but do not prevent invalid values!
-       # Settings have conditions that enable/disable this setting depending on other settings. (Ex: Dual-extrusion)
+       """
+               A setting object contains a configuration setting. These are globally accessible trough the quick access functions
+               and trough the settingsDictionary function.
+               Settings can be:
+               * profile settings (settings that effect the slicing process and the print result)
+               * preferences (settings that effect how cura works and acts)
+               * machine settings (settings that relate to the physical configuration of your machine)
+               * alterations (bad name copied from Skeinforge. These are the start/end code pieces)
+               Settings have validators that check if the value is valid, but do not prevent invalid values!
+               Settings have conditions that enable/disable this setting depending on other settings. (Ex: Dual-extrusion)
+       """
        def __init__(self, name, default, type, category, subcategory):
                self._name = name
                self._label = name
index d820b6fbc8cb9c2c50d33fca0bdcc6c0ac52dd5c..87b3e4e2d9641e7a2a69f1bbe9745aae8e6d4c3b 100644 (file)
@@ -26,6 +26,10 @@ from Cura.util import version
 from Cura.util import gcodeInterpreter
 
 def getEngineFilename():
+       """
+               Finds and returns the path to the current engine executable. This is OS depended.
+       :return: The full path to the engine executable.
+       """
        if platform.system() == 'Windows':
                if version.isDevVersion() and os.path.exists('C:/Software/Cura_SteamEngine/_bin/Release/Cura_SteamEngine.exe'):
                        return 'C:/Software/Cura_SteamEngine/_bin/Release/Cura_SteamEngine.exe'
@@ -38,13 +42,11 @@ def getEngineFilename():
                return '/usr/local/bin/CuraEngine'
        return os.path.abspath(os.path.join(os.path.dirname(__file__), '../..', 'CuraEngine'))
 
-def getTempFilename():
-       warnings.simplefilter('ignore')
-       ret = os.tempnam(None, "Cura_Tmp")
-       warnings.simplefilter('default')
-       return ret
-
 class EngineResult(object):
+       """
+       Result from running the CuraEngine.
+       Contains the engine log, polygons retrieved from the engine, the GCode and some meta-data.
+       """
        def __init__(self):
                self._engineLog = []
                self._gcodeData = StringIO.StringIO()
@@ -156,6 +158,11 @@ class EngineResult(object):
                        pass
 
 class Engine(object):
+       """
+       Class used to communicate with the CuraEngine.
+       The CuraEngine is ran as a 2nd process and reports back information trough stderr.
+       GCode trough stdout and has a socket connection for polygon information and loading the 3D model into the engine.
+       """
        GUI_CMD_REQUEST_MESH = 0x01
        GUI_CMD_SEND_POLYGONS = 0x02
 
index 6e0615c65210e6b27658e18785f9ded07cb317fa..5aa6710a3c16745a99cfd238883c967829a6b939 100644 (file)
@@ -9,6 +9,10 @@ import httplib as httpclient
 import urllib
 
 class httpUploadDataStream(object):
+       """
+       For http uploads we need a readable/writable datasteam to use with the httpclient.HTTPSConnection class.
+       This is used to facilitate file uploads towards Youmagine.
+       """
        def __init__(self, progressCallback):
                self._dataList = []
                self._totalLength = 0
@@ -38,6 +42,10 @@ class httpUploadDataStream(object):
                return self._totalLength
 
 class Youmagine(object):
+       """
+       Youmagine connection object. Has various functions to communicate with Youmagine.
+       These functions are blocking and thus this class should be used from a thread.
+       """
        def __init__(self, authToken, progressCallback = None):
                self._hostUrl = 'api.youmagine.com'
                self._viewUrl = 'www.youmagine.com'
@@ -197,8 +205,11 @@ class Youmagine(object):
                return {'error': error}
 
 
-#Fake Youmagine class to test without internet
 class FakeYoumagine(Youmagine):
+       """
+       Fake Youmagine class to test without internet, acts the same as the YouMagine class, but without going to the internet.
+       Assists in testing UI features.
+       """
        def __init__(self, authToken, callback):
                super(FakeYoumagine, self).__init__(authToken)
                self._authUrl = 'file:///C:/Models/output.html'