mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-12-05 16:51:12 -07:00
Merge branch 'master' of https://github.com/Ultimaker/Cura
This commit is contained in:
commit
6c30e1d107
49 changed files with 30730 additions and 636 deletions
|
|
@ -48,15 +48,15 @@ class BuildVolume(SceneNode):
|
|||
|
||||
if not self._material:
|
||||
self._material = renderer.createMaterial(
|
||||
Resources.getPath(Resources.ShadersLocation, 'basic.vert'),
|
||||
Resources.getPath(Resources.ShadersLocation, 'vertexcolor.frag')
|
||||
Resources.getPath(Resources.ShadersLocation, "basic.vert"),
|
||||
Resources.getPath(Resources.ShadersLocation, "vertexcolor.frag")
|
||||
)
|
||||
self._grid_material = renderer.createMaterial(
|
||||
Resources.getPath(Resources.ShadersLocation, 'basic.vert'),
|
||||
Resources.getPath(Resources.ShadersLocation, 'grid.frag')
|
||||
Resources.getPath(Resources.ShadersLocation, "basic.vert"),
|
||||
Resources.getPath(Resources.ShadersLocation, "grid.frag")
|
||||
)
|
||||
self._grid_material.setUniformValue('u_gridColor0', Color(245, 245, 245, 255))
|
||||
self._grid_material.setUniformValue('u_gridColor1', Color(205, 202, 201, 255))
|
||||
self._grid_material.setUniformValue("u_gridColor0", Color(245, 245, 245, 255))
|
||||
self._grid_material.setUniformValue("u_gridColor1", Color(205, 202, 201, 255))
|
||||
|
||||
renderer.queueNode(self, material = self._material, mode = Renderer.RenderLines)
|
||||
renderer.queueNode(self, mesh = self._grid_mesh, material = self._grid_material)
|
||||
|
|
|
|||
|
|
@ -47,9 +47,9 @@ class ConvexHullNode(SceneNode):
|
|||
|
||||
def render(self, renderer):
|
||||
if not self._material:
|
||||
self._material = renderer.createMaterial(Resources.getPath(Resources.ShadersLocation, 'basic.vert'), Resources.getPath(Resources.ShadersLocation, 'color.frag'))
|
||||
self._material = renderer.createMaterial(Resources.getPath(Resources.ShadersLocation, "basic.vert"), Resources.getPath(Resources.ShadersLocation, "color.frag"))
|
||||
|
||||
self._material.setUniformValue('u_color', Color(35, 35, 35, 128))
|
||||
self._material.setUniformValue("u_color", Color(35, 35, 35, 128))
|
||||
|
||||
renderer.queueNode(self, material = self._material, transparent = True)
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ from UM.Operations.RemoveSceneNodeOperation import RemoveSceneNodeOperation
|
|||
from UM.Operations.GroupedOperation import GroupedOperation
|
||||
from UM.Operations.SetTransformOperation import SetTransformOperation
|
||||
|
||||
from UM.i18n import i18nCatalog
|
||||
|
||||
from . import PlatformPhysics
|
||||
from . import BuildVolume
|
||||
from . import CameraAnimation
|
||||
|
|
@ -33,49 +35,42 @@ from PyQt5.QtGui import QColor
|
|||
import sys
|
||||
import os.path
|
||||
import numpy
|
||||
numpy.seterr(all='ignore')
|
||||
numpy.seterr(all="ignore")
|
||||
|
||||
class PrinterApplication(QtApplication):
|
||||
class CuraApplication(QtApplication):
|
||||
def __init__(self):
|
||||
super().__init__(name = 'cura', version = "14.2.1")
|
||||
if not hasattr(sys, "frozen"):
|
||||
Resources.addResourcePath(os.path.join(os.path.abspath(os.path.dirname(__file__)), ".."))
|
||||
|
||||
if not hasattr(sys, 'frozen'):
|
||||
Resources.addResourcePath(os.path.join(os.path.abspath(os.path.dirname(__file__)), '..'))
|
||||
super().__init__(name = "cura", version = "master")
|
||||
|
||||
self.setRequiredPlugins([
|
||||
'CuraEngineBackend',
|
||||
'MeshView',
|
||||
'LayerView',
|
||||
'STLReader',
|
||||
'SelectionTool',
|
||||
'CameraTool',
|
||||
'GCodeWriter',
|
||||
'LocalFileStorage'
|
||||
"CuraEngineBackend",
|
||||
"MeshView",
|
||||
"LayerView",
|
||||
"STLReader",
|
||||
"SelectionTool",
|
||||
"CameraTool",
|
||||
"GCodeWriter",
|
||||
"LocalFileStorage"
|
||||
])
|
||||
self._physics = None
|
||||
self._volume = None
|
||||
self._platform = None
|
||||
self._output_devices = {
|
||||
'local_file': {
|
||||
'id': 'local_file',
|
||||
'function': self._writeToLocalFile,
|
||||
'description': 'Save to Disk',
|
||||
'icon': 'save',
|
||||
'priority': 0
|
||||
}
|
||||
}
|
||||
self._output_devices = {}
|
||||
self._print_information = None
|
||||
self._i18n_catalog = None
|
||||
|
||||
self.activeMachineChanged.connect(self._onActiveMachineChanged)
|
||||
|
||||
Preferences.getInstance().addPreference('cura/active_machine', '')
|
||||
Preferences.getInstance().addPreference('cura/active_mode', 'simple')
|
||||
Preferences.getInstance().addPreference("cura/active_machine", "")
|
||||
Preferences.getInstance().addPreference("cura/active_mode", "simple")
|
||||
|
||||
## Handle loading of all plugin types (and the backend explicitly)
|
||||
# \sa PluginRegistery
|
||||
def _loadPlugins(self):
|
||||
if not hasattr(sys, 'frozen'):
|
||||
self._plugin_registry.addPluginLocation(os.path.join(os.path.abspath(os.path.dirname(__file__)), '..', 'plugins'))
|
||||
if not hasattr(sys, "frozen"):
|
||||
self._plugin_registry.addPluginLocation(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "plugins"))
|
||||
|
||||
self._plugin_registry.loadPlugins({ "type": "logger"})
|
||||
self._plugin_registry.loadPlugins({ "type": "storage_device" })
|
||||
|
|
@ -85,10 +80,20 @@ class PrinterApplication(QtApplication):
|
|||
self._plugin_registry.loadPlugins({ "type": "tool" })
|
||||
self._plugin_registry.loadPlugins({ "type": "extension" })
|
||||
|
||||
self._plugin_registry.loadPlugin('CuraEngineBackend')
|
||||
self._plugin_registry.loadPlugin("CuraEngineBackend")
|
||||
|
||||
def run(self):
|
||||
self.showSplashMessage('Setting up scene...')
|
||||
self._i18n_catalog = i18nCatalog("cura");
|
||||
|
||||
self.addOutputDevice("local_file", {
|
||||
"id": "local_file",
|
||||
"function": self._writeToLocalFile,
|
||||
"description": self._i18n_catalog.i18nc("Save button tooltip", "Save to Disk"),
|
||||
"icon": "save",
|
||||
"priority": 0
|
||||
})
|
||||
|
||||
self.showSplashMessage(self._i18n_catalog.i18nc("Splash screen message", "Setting up scene..."))
|
||||
|
||||
controller = self.getController()
|
||||
|
||||
|
|
@ -96,7 +101,7 @@ class PrinterApplication(QtApplication):
|
|||
controller.setCameraTool("CameraTool")
|
||||
controller.setSelectionTool("SelectionTool")
|
||||
|
||||
t = controller.getTool('TranslateTool')
|
||||
t = controller.getTool("TranslateTool")
|
||||
if t:
|
||||
t.setEnabledAxis([ToolHandle.XAxis, ToolHandle.ZAxis])
|
||||
|
||||
|
|
@ -112,25 +117,25 @@ class PrinterApplication(QtApplication):
|
|||
|
||||
self._physics = PlatformPhysics.PlatformPhysics(controller, self._volume)
|
||||
|
||||
camera = Camera('3d', root)
|
||||
camera = Camera("3d", root)
|
||||
camera.setPosition(Vector(-150, 150, 300))
|
||||
camera.setPerspective(True)
|
||||
camera.lookAt(Vector(0, 0, 0))
|
||||
|
||||
self._camera_animation = CameraAnimation.CameraAnimation()
|
||||
self._camera_animation.setCameraTool(self.getController().getTool('CameraTool'))
|
||||
self._camera_animation.setCameraTool(self.getController().getTool("CameraTool"))
|
||||
|
||||
controller.getScene().setActiveCamera('3d')
|
||||
controller.getScene().setActiveCamera("3d")
|
||||
|
||||
self.showSplashMessage('Loading interface...')
|
||||
self.showSplashMessage(self._i18n_catalog.i18nc("Splash screen message", "Loading interface..."))
|
||||
|
||||
self.setMainQml(Resources.getPath(Resources.QmlFilesLocation, "Printer.qml"))
|
||||
self.setMainQml(Resources.getPath(Resources.QmlFilesLocation, "Cura.qml"))
|
||||
self.initializeEngine()
|
||||
|
||||
self.getStorageDevice('LocalFileStorage').removableDrivesChanged.connect(self._removableDrivesChanged)
|
||||
self.getStorageDevice("LocalFileStorage").removableDrivesChanged.connect(self._removableDrivesChanged)
|
||||
|
||||
if self.getMachines():
|
||||
active_machine_pref = Preferences.getInstance().getValue('cura/active_machine')
|
||||
active_machine_pref = Preferences.getInstance().getValue("cura/active_machine")
|
||||
if active_machine_pref:
|
||||
for machine in self.getMachines():
|
||||
if machine.getName() == active_machine_pref:
|
||||
|
|
@ -148,16 +153,16 @@ class PrinterApplication(QtApplication):
|
|||
self.exec_()
|
||||
|
||||
def registerObjects(self, engine):
|
||||
engine.rootContext().setContextProperty('Printer', self)
|
||||
engine.rootContext().setContextProperty("Printer", self)
|
||||
self._print_information = PrintInformation.PrintInformation()
|
||||
engine.rootContext().setContextProperty('PrintInformation', self._print_information)
|
||||
engine.rootContext().setContextProperty("PrintInformation", self._print_information)
|
||||
|
||||
def onSelectionChanged(self):
|
||||
if Selection.hasSelection():
|
||||
if not self.getController().getActiveTool():
|
||||
self.getController().setActiveTool('TranslateTool')
|
||||
self.getController().setActiveTool("TranslateTool")
|
||||
|
||||
self._camera_animation.setStart(self.getController().getTool('CameraTool').getOrigin())
|
||||
self._camera_animation.setStart(self.getController().getTool("CameraTool").getOrigin())
|
||||
self._camera_animation.setTarget(Selection.getSelectedObject(0).getWorldPosition())
|
||||
self._camera_animation.start()
|
||||
else:
|
||||
|
|
@ -167,7 +172,7 @@ class PrinterApplication(QtApplication):
|
|||
requestAddPrinter = pyqtSignal()
|
||||
|
||||
## Remove an object from the scene
|
||||
@pyqtSlot('quint64')
|
||||
@pyqtSlot("quint64")
|
||||
def deleteObject(self, object_id):
|
||||
object = self.getController().getScene().findObject(object_id)
|
||||
|
||||
|
|
@ -176,7 +181,7 @@ class PrinterApplication(QtApplication):
|
|||
op.push()
|
||||
|
||||
## Create a number of copies of existing object.
|
||||
@pyqtSlot('quint64', int)
|
||||
@pyqtSlot("quint64", int)
|
||||
def multiplyObject(self, object_id, count):
|
||||
node = self.getController().getScene().findObject(object_id)
|
||||
|
||||
|
|
@ -192,7 +197,7 @@ class PrinterApplication(QtApplication):
|
|||
op.push()
|
||||
|
||||
## Center object on platform.
|
||||
@pyqtSlot('quint64')
|
||||
@pyqtSlot("quint64")
|
||||
def centerObject(self, object_id):
|
||||
node = self.getController().getScene().findObject(object_id)
|
||||
|
||||
|
|
@ -286,15 +291,15 @@ class PrinterApplication(QtApplication):
|
|||
|
||||
outputDevicesChanged = pyqtSignal()
|
||||
|
||||
@pyqtProperty('QVariantMap', notify = outputDevicesChanged)
|
||||
@pyqtProperty("QVariantMap", notify = outputDevicesChanged)
|
||||
def outputDevices(self):
|
||||
return self._output_devices
|
||||
|
||||
@pyqtProperty('QStringList', notify = outputDevicesChanged)
|
||||
@pyqtProperty("QStringList", notify = outputDevicesChanged)
|
||||
def outputDeviceNames(self):
|
||||
return self._output_devices.keys()
|
||||
|
||||
@pyqtSlot(str, result = 'QVariant')
|
||||
@pyqtSlot(str, result = "QVariant")
|
||||
def getSettingValue(self, key):
|
||||
if not self.getActiveMachine():
|
||||
return None
|
||||
|
|
@ -302,7 +307,7 @@ class PrinterApplication(QtApplication):
|
|||
return self.getActiveMachine().getSettingValueByKey(key)
|
||||
|
||||
## Change setting by key value pair
|
||||
@pyqtSlot(str, 'QVariant')
|
||||
@pyqtSlot(str, "QVariant")
|
||||
def setSettingValue(self, key, value):
|
||||
if not self.getActiveMachine():
|
||||
return
|
||||
|
|
@ -332,7 +337,7 @@ class PrinterApplication(QtApplication):
|
|||
|
||||
@pyqtSlot(str)
|
||||
def writeToOutputDevice(self, device):
|
||||
self._output_devices[device]['function'](device)
|
||||
self._output_devices[device]["function"](device)
|
||||
|
||||
writeToLocalFileRequested = pyqtSignal()
|
||||
|
||||
|
|
@ -345,12 +350,12 @@ class PrinterApplication(QtApplication):
|
|||
continue
|
||||
|
||||
try:
|
||||
path = self.getStorageDevice('LocalFileStorage').getRemovableDrives()[device]
|
||||
path = self.getStorageDevice("LocalFileStorage").getRemovableDrives()[device]
|
||||
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
|
||||
|
||||
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._sdcard = device
|
||||
|
|
@ -359,21 +364,21 @@ class PrinterApplication(QtApplication):
|
|||
return
|
||||
|
||||
def _removableDrivesChanged(self):
|
||||
drives = self.getStorageDevice('LocalFileStorage').getRemovableDrives()
|
||||
drives = self.getStorageDevice("LocalFileStorage").getRemovableDrives()
|
||||
for drive in drives:
|
||||
if drive not in self._output_devices:
|
||||
self.addOutputDevice(drive, {
|
||||
'id': drive,
|
||||
'function': self._writeToSD,
|
||||
'description': 'Save to SD Card {0}'.format(drive),
|
||||
'icon': 'save_sd',
|
||||
'priority': 1
|
||||
"id": drive,
|
||||
"function": self._writeToSD,
|
||||
"description": self._i18n_catalog.i18nc("Save button tooltip. {0} is sd card name", "Save to SD Card {0}".format(drive)),
|
||||
"icon": "save_sd",
|
||||
"priority": 1
|
||||
})
|
||||
|
||||
drives_to_remove = []
|
||||
for device in self._output_devices:
|
||||
if device not in drives:
|
||||
if self._output_devices[device]['function'] == self._writeToSD:
|
||||
if self._output_devices[device]["function"] == self._writeToSD:
|
||||
drives_to_remove.append(device)
|
||||
|
||||
for drive in drives_to_remove:
|
||||
|
|
@ -382,13 +387,13 @@ class PrinterApplication(QtApplication):
|
|||
def _onActiveMachineChanged(self):
|
||||
machine = self.getActiveMachine()
|
||||
if machine:
|
||||
Preferences.getInstance().setValue('cura/active_machine', machine.getName())
|
||||
Preferences.getInstance().setValue("cura/active_machine", machine.getName())
|
||||
|
||||
self._volume.setWidth(machine.getSettingValueByKey('machine_width'))
|
||||
self._volume.setHeight(machine.getSettingValueByKey('machine_height'))
|
||||
self._volume.setDepth(machine.getSettingValueByKey('machine_depth'))
|
||||
self._volume.setWidth(machine.getSettingValueByKey("machine_width"))
|
||||
self._volume.setHeight(machine.getSettingValueByKey("machine_height"))
|
||||
self._volume.setDepth(machine.getSettingValueByKey("machine_depth"))
|
||||
|
||||
disallowed_areas = machine.getSettingValueByKey('machine_disallowed_areas')
|
||||
disallowed_areas = machine.getSettingValueByKey("machine_disallowed_areas")
|
||||
areas = []
|
||||
if disallowed_areas:
|
||||
|
||||
|
|
@ -403,22 +408,27 @@ class PrinterApplication(QtApplication):
|
|||
|
||||
self._volume.rebuild()
|
||||
|
||||
if self.getController().getTool('ScaleTool'):
|
||||
self.getController().getTool('ScaleTool').setMaximumBounds(self._volume.getBoundingBox())
|
||||
if self.getController().getTool("ScaleTool"):
|
||||
self.getController().getTool("ScaleTool").setMaximumBounds(self._volume.getBoundingBox())
|
||||
|
||||
offset = machine.getSettingValueByKey('machine_platform_offset')
|
||||
offset = machine.getSettingValueByKey("machine_platform_offset")
|
||||
if offset:
|
||||
self._platform.setPosition(Vector(offset[0], offset[1], offset[2]))
|
||||
else:
|
||||
self._platform.setPosition(Vector(0.0, 0.0, 0.0))
|
||||
|
||||
def _onWriteToSDFinished(self, job):
|
||||
message = Message("Saved to SD Card {0} as {1}".format(job._sdcard, job.getFileName()))
|
||||
message.addAction("Eject", "eject", "Eject SD Card {0}".format(job._sdcard))
|
||||
message = Message(self._i18n_catalog.i18nc("Saved to SD message, {0} is sdcard, {1} is filename", "Saved to SD Card {0} as {1}").format(job._sdcard, job.getFileName()))
|
||||
message.addAction(
|
||||
"eject",
|
||||
self._i18n_catalog.i18nc("Message action", "Eject"),
|
||||
"eject",
|
||||
self._i18n_catalog.i18nc("Message action tooltip, {0} is sdcard", "Eject SD Card {0}".format(job._sdcard))
|
||||
)
|
||||
message._sdcard = job._sdcard
|
||||
message.actionTriggered.connect(self._onMessageActionTriggered)
|
||||
message.show()
|
||||
|
||||
def _onMessageActionTriggered(self, message, action):
|
||||
if action == "Eject":
|
||||
if action == "eject":
|
||||
self.getStorageDevice("LocalFileStorage").ejectRemovableDrive(message._sdcard)
|
||||
|
|
@ -52,8 +52,8 @@ class PlatformPhysics:
|
|||
move_vector.setY(-bbox.bottom)
|
||||
|
||||
# If there is no convex hull for the node, start calculating it and continue.
|
||||
if not hasattr(node, '_convex_hull'):
|
||||
if not hasattr(node, '_convex_hull_job'):
|
||||
if not hasattr(node, "_convex_hull"):
|
||||
if not hasattr(node, "_convex_hull_job"):
|
||||
job = ConvexHullJob.ConvexHullJob(node)
|
||||
job.start()
|
||||
node._convex_hull_job = job
|
||||
|
|
@ -65,7 +65,7 @@ class PlatformPhysics:
|
|||
continue
|
||||
|
||||
# Ignore nodes that do not have the right properties set.
|
||||
if not hasattr(other_node, '_convex_hull') or not other_node.getBoundingBox():
|
||||
if not hasattr(other_node, "_convex_hull") or not other_node.getBoundingBox():
|
||||
continue
|
||||
|
||||
# Check to see if the bounding boxes intersect. If not, we can ignore the node as there is no way the hull intersects.
|
||||
|
|
|
|||
|
|
@ -27,4 +27,4 @@ class PlatformPhysicsOperation(Operation):
|
|||
return group
|
||||
|
||||
def __repr__(self):
|
||||
return 'PlatformPhysicsOperation(t = {0})'.format(self._position)
|
||||
return "PlatformPhysicsOperation(t = {0})".format(self._position)
|
||||
|
|
|
|||
|
|
@ -168,27 +168,27 @@ class PrintInformation(QObject):
|
|||
|
||||
if not self._low_quality_settings:
|
||||
self._low_quality_settings = MachineSettings()
|
||||
self._low_quality_settings.loadSettingsFromFile(Resources.getPath(Resources.SettingsLocation, self._current_settings.getTypeID() + '.json'))
|
||||
self._low_quality_settings.loadValuesFromFile(Resources.getPath(Resources.SettingsLocation, 'profiles', 'low_quality.conf'))
|
||||
self._low_quality_settings.loadSettingsFromFile(Resources.getPath(Resources.SettingsLocation, self._current_settings.getTypeID() + ".json"))
|
||||
self._low_quality_settings.loadValuesFromFile(Resources.getPath(Resources.SettingsLocation, "profiles", "low_quality.conf"))
|
||||
|
||||
if not self._high_quality_settings:
|
||||
self._high_quality_settings = MachineSettings()
|
||||
self._high_quality_settings.loadSettingsFromFile(Resources.getPath(Resources.SettingsLocation, self._current_settings.getTypeID() + '.json'))
|
||||
self._high_quality_settings.loadValuesFromFile(Resources.getPath(Resources.SettingsLocation, 'profiles', 'high_quality.conf'))
|
||||
self._high_quality_settings.loadSettingsFromFile(Resources.getPath(Resources.SettingsLocation, self._current_settings.getTypeID() + ".json"))
|
||||
self._high_quality_settings.loadValuesFromFile(Resources.getPath(Resources.SettingsLocation, "profiles", "high_quality.conf"))
|
||||
|
||||
for key, options in self._interpolation_settings.items():
|
||||
minimum_value = None
|
||||
if options['minimum'] == 'low':
|
||||
if options["minimum"] == "low":
|
||||
minimum_value = self._low_quality_settings.getSettingValueByKey(key)
|
||||
elif options['minimum'] == 'high':
|
||||
elif options["minimum"] == "high":
|
||||
minimum_value = self._high_quality_settings.getSettingValueByKey(key)
|
||||
else:
|
||||
continue
|
||||
|
||||
maximum_value = None
|
||||
if options['maximum'] == 'low':
|
||||
if options["maximum"] == "low":
|
||||
maximum_value = self._low_quality_settings.getSettingValueByKey(key)
|
||||
elif options['maximum'] == 'high':
|
||||
elif options["maximum"] == "high":
|
||||
maximum_value = self._high_quality_settings.getSettingValueByKey(key)
|
||||
else:
|
||||
continue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue