mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 23:46:22 -06:00
Cleanup & documentation
This commit is contained in:
parent
d81a2e7a15
commit
c58ed21406
1 changed files with 27 additions and 12 deletions
|
@ -64,6 +64,8 @@ class PrinterApplication(QtApplication):
|
||||||
Preferences.getInstance().addPreference('cura/active_machine', '')
|
Preferences.getInstance().addPreference('cura/active_machine', '')
|
||||||
Preferences.getInstance().addPreference('cura/active_mode', 'simple')
|
Preferences.getInstance().addPreference('cura/active_mode', 'simple')
|
||||||
|
|
||||||
|
## Handle loading of all plugin types (and the backend explicitly)
|
||||||
|
# \sa PluginRegistery
|
||||||
def _loadPlugins(self):
|
def _loadPlugins(self):
|
||||||
self._plugin_registry.loadPlugins({ "type": "logger"})
|
self._plugin_registry.loadPlugins({ "type": "logger"})
|
||||||
self._plugin_registry.loadPlugins({ "type": "storage_device" })
|
self._plugin_registry.loadPlugins({ "type": "storage_device" })
|
||||||
|
@ -154,6 +156,7 @@ class PrinterApplication(QtApplication):
|
||||||
|
|
||||||
requestAddPrinter = pyqtSignal()
|
requestAddPrinter = pyqtSignal()
|
||||||
|
|
||||||
|
## Remove an object from the scene
|
||||||
@pyqtSlot('quint64')
|
@pyqtSlot('quint64')
|
||||||
def deleteObject(self, object_id):
|
def deleteObject(self, object_id):
|
||||||
object = self.getController().getScene().findObject(object_id)
|
object = self.getController().getScene().findObject(object_id)
|
||||||
|
@ -161,7 +164,8 @@ class PrinterApplication(QtApplication):
|
||||||
if object:
|
if object:
|
||||||
op = RemoveSceneNodeOperation(object)
|
op = RemoveSceneNodeOperation(object)
|
||||||
op.push()
|
op.push()
|
||||||
|
|
||||||
|
## Create a number of copies of existing object.
|
||||||
@pyqtSlot('quint64', int)
|
@pyqtSlot('quint64', int)
|
||||||
def multiplyObject(self, object_id, count):
|
def multiplyObject(self, object_id, count):
|
||||||
node = self.getController().getScene().findObject(object_id)
|
node = self.getController().getScene().findObject(object_id)
|
||||||
|
@ -176,7 +180,8 @@ class PrinterApplication(QtApplication):
|
||||||
new_node.setSelectable(True)
|
new_node.setSelectable(True)
|
||||||
op.addOperation(AddSceneNodeOperation(new_node, node.getParent()))
|
op.addOperation(AddSceneNodeOperation(new_node, node.getParent()))
|
||||||
op.push()
|
op.push()
|
||||||
|
|
||||||
|
## Center object on platform.
|
||||||
@pyqtSlot('quint64')
|
@pyqtSlot('quint64')
|
||||||
def centerObject(self, object_id):
|
def centerObject(self, object_id):
|
||||||
node = self.getController().getScene().findObject(object_id)
|
node = self.getController().getScene().findObject(object_id)
|
||||||
|
@ -186,7 +191,8 @@ class PrinterApplication(QtApplication):
|
||||||
transform.setTranslation(Vector(0, 0, 0))
|
transform.setTranslation(Vector(0, 0, 0))
|
||||||
op = SetTransformOperation(node, transform)
|
op = SetTransformOperation(node, transform)
|
||||||
op.push()
|
op.push()
|
||||||
|
|
||||||
|
## Delete all mesh data on the scene.
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def deleteAll(self):
|
def deleteAll(self):
|
||||||
nodes = []
|
nodes = []
|
||||||
|
@ -202,7 +208,8 @@ class PrinterApplication(QtApplication):
|
||||||
op.addOperation(RemoveSceneNodeOperation(node))
|
op.addOperation(RemoveSceneNodeOperation(node))
|
||||||
|
|
||||||
op.push()
|
op.push()
|
||||||
|
|
||||||
|
## Reset all translation on nodes with mesh data.
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def resetAllTranslation(self):
|
def resetAllTranslation(self):
|
||||||
nodes = []
|
nodes = []
|
||||||
|
@ -220,7 +227,8 @@ class PrinterApplication(QtApplication):
|
||||||
op.addOperation(SetTransformOperation(node, transform))
|
op.addOperation(SetTransformOperation(node, transform))
|
||||||
|
|
||||||
op.push()
|
op.push()
|
||||||
|
|
||||||
|
## Reset all transformations on nodes with mesh data.
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def resetAll(self):
|
def resetAll(self):
|
||||||
nodes = []
|
nodes = []
|
||||||
|
@ -237,7 +245,8 @@ class PrinterApplication(QtApplication):
|
||||||
op.addOperation(SetTransformOperation(node, transform))
|
op.addOperation(SetTransformOperation(node, transform))
|
||||||
|
|
||||||
op.push()
|
op.push()
|
||||||
|
|
||||||
|
## Reload all mesh data on the screen from file.
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def reloadAll(self):
|
def reloadAll(self):
|
||||||
nodes = []
|
nodes = []
|
||||||
|
@ -253,7 +262,9 @@ class PrinterApplication(QtApplication):
|
||||||
job = ReadMeshJob(file_name)
|
job = ReadMeshJob(file_name)
|
||||||
job.finished.connect(lambda j: node.setMeshData(j.getResult()))
|
job.finished.connect(lambda j: node.setMeshData(j.getResult()))
|
||||||
job.start()
|
job.start()
|
||||||
|
|
||||||
|
## Get logging data of the backend engine
|
||||||
|
# \returns \type{string} Logging data
|
||||||
@pyqtSlot(result=str)
|
@pyqtSlot(result=str)
|
||||||
def getEngineLog(self):
|
def getEngineLog(self):
|
||||||
log = ""
|
log = ""
|
||||||
|
@ -279,7 +290,8 @@ class PrinterApplication(QtApplication):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return self.getActiveMachine().getSettingValueByKey(key)
|
return self.getActiveMachine().getSettingValueByKey(key)
|
||||||
|
|
||||||
|
## Change setting by key value pair
|
||||||
@pyqtSlot(str, 'QVariant')
|
@pyqtSlot(str, 'QVariant')
|
||||||
def setSettingValue(self, key, value):
|
def setSettingValue(self, key, value):
|
||||||
if not self.getActiveMachine():
|
if not self.getActiveMachine():
|
||||||
|
@ -289,8 +301,8 @@ class PrinterApplication(QtApplication):
|
||||||
|
|
||||||
## Add an output device that can be written to.
|
## Add an output device that can be written to.
|
||||||
#
|
#
|
||||||
# \param id The identifier used to identify the device.
|
# \param id \type{string} The identifier used to identify the device.
|
||||||
# \param device A dictionary of device information.
|
# \param device \type{StorageDevice} A dictionary of device information.
|
||||||
# It should contains the following:
|
# It should contains the following:
|
||||||
# - function: A function to be called when trying to write to the device. Will be passed the device id as first parameter.
|
# - function: A function to be called when trying to write to the device. Will be passed the device id as first parameter.
|
||||||
# - description: A translated string containing a description of what happens when writing to the device.
|
# - description: A translated string containing a description of what happens when writing to the device.
|
||||||
|
@ -299,7 +311,10 @@ class PrinterApplication(QtApplication):
|
||||||
def addOutputDevice(self, id, device):
|
def addOutputDevice(self, id, device):
|
||||||
self._output_devices[id] = device
|
self._output_devices[id] = device
|
||||||
self.outputDevicesChanged.emit()
|
self.outputDevicesChanged.emit()
|
||||||
|
|
||||||
|
## Remove output device
|
||||||
|
# \param id \type{string} The identifier used to identify the device.
|
||||||
|
# \sa PrinterApplication::addOutputDevice()
|
||||||
def removeOutputDevice(self, id):
|
def removeOutputDevice(self, id):
|
||||||
if id in self._output_devices:
|
if id in self._output_devices:
|
||||||
del self._output_devices[id]
|
del self._output_devices[id]
|
||||||
|
@ -324,7 +339,7 @@ class PrinterApplication(QtApplication):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
Logger.log('e', 'Tried to write to unknown SD card %s', device)
|
Logger.log('e', 'Tried to write to unknown SD card %s', device)
|
||||||
return
|
return
|
||||||
|
|
||||||
filename = os.path.join(path, node.getName()[0:node.getName().rfind('.')] + '.gcode')
|
filename = os.path.join(path, node.getName()[0:node.getName().rfind('.')] + '.gcode')
|
||||||
|
|
||||||
job = WriteMeshJob(filename, node.getMeshData())
|
job = WriteMeshJob(filename, node.getMeshData())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue