This commit is contained in:
Tim Kuipers 2015-12-01 13:46:17 +01:00
commit 4f8ac05851
18 changed files with 85 additions and 78 deletions

View File

@ -41,6 +41,7 @@ Third party plugins
-------------
* [Print time calculator](https://github.com/nallath/PrintCostCalculator)
* [Post processing plugin](https://github.com/nallath/PostProcessingPlugin)
* [Barbarian Plugin](https://github.com/nallath/BarbarianPlugin) Simple scale tool for imperial to metric.
Making profiles for other printers
----------------------------------

View File

@ -83,38 +83,38 @@ class BuildVolume(SceneNode):
if self._width == 0 or self._height == 0 or self._depth == 0:
return
minW = -self._width / 2
maxW = self._width / 2
minH = 0.0
maxH = self._height
minD = -self._depth / 2
maxD = self._depth / 2
min_w = -self._width / 2
max_w = self._width / 2
min_h = 0.0
max_h = self._height
min_d = -self._depth / 2
max_d = self._depth / 2
mb = MeshBuilder()
mb.addLine(Vector(minW, minH, minD), Vector(maxW, minH, minD), color = self.VolumeOutlineColor)
mb.addLine(Vector(minW, minH, minD), Vector(minW, maxH, minD), color = self.VolumeOutlineColor)
mb.addLine(Vector(minW, maxH, minD), Vector(maxW, maxH, minD), color = self.VolumeOutlineColor)
mb.addLine(Vector(maxW, minH, minD), Vector(maxW, maxH, minD), color = self.VolumeOutlineColor)
mb.addLine(Vector(min_w, min_h, min_d), Vector(max_w, min_h, min_d), color = self.VolumeOutlineColor)
mb.addLine(Vector(min_w, min_h, min_d), Vector(min_w, max_h, min_d), color = self.VolumeOutlineColor)
mb.addLine(Vector(min_w, max_h, min_d), Vector(max_w, max_h, min_d), color = self.VolumeOutlineColor)
mb.addLine(Vector(max_w, min_h, min_d), Vector(max_w, max_h, min_d), color = self.VolumeOutlineColor)
mb.addLine(Vector(minW, minH, maxD), Vector(maxW, minH, maxD), color = self.VolumeOutlineColor)
mb.addLine(Vector(minW, minH, maxD), Vector(minW, maxH, maxD), color = self.VolumeOutlineColor)
mb.addLine(Vector(minW, maxH, maxD), Vector(maxW, maxH, maxD), color = self.VolumeOutlineColor)
mb.addLine(Vector(maxW, minH, maxD), Vector(maxW, maxH, maxD), color = self.VolumeOutlineColor)
mb.addLine(Vector(min_w, min_h, max_d), Vector(max_w, min_h, max_d), color = self.VolumeOutlineColor)
mb.addLine(Vector(min_w, min_h, max_d), Vector(min_w, max_h, max_d), color = self.VolumeOutlineColor)
mb.addLine(Vector(min_w, max_h, max_d), Vector(max_w, max_h, max_d), color = self.VolumeOutlineColor)
mb.addLine(Vector(max_w, min_h, max_d), Vector(max_w, max_h, max_d), color = self.VolumeOutlineColor)
mb.addLine(Vector(minW, minH, minD), Vector(minW, minH, maxD), color = self.VolumeOutlineColor)
mb.addLine(Vector(maxW, minH, minD), Vector(maxW, minH, maxD), color = self.VolumeOutlineColor)
mb.addLine(Vector(minW, maxH, minD), Vector(minW, maxH, maxD), color = self.VolumeOutlineColor)
mb.addLine(Vector(maxW, maxH, minD), Vector(maxW, maxH, maxD), color = self.VolumeOutlineColor)
mb.addLine(Vector(min_w, min_h, min_d), Vector(min_w, min_h, max_d), color = self.VolumeOutlineColor)
mb.addLine(Vector(max_w, min_h, min_d), Vector(max_w, min_h, max_d), color = self.VolumeOutlineColor)
mb.addLine(Vector(min_w, max_h, min_d), Vector(min_w, max_h, max_d), color = self.VolumeOutlineColor)
mb.addLine(Vector(max_w, max_h, min_d), Vector(max_w, max_h, max_d), color = self.VolumeOutlineColor)
self.setMeshData(mb.getData())
mb = MeshBuilder()
mb.addQuad(
Vector(minW, minH, minD),
Vector(maxW, minH, minD),
Vector(maxW, minH, maxD),
Vector(minW, minH, maxD)
Vector(min_w, min_h, min_d),
Vector(max_w, min_h, min_d),
Vector(max_w, min_h, max_d),
Vector(min_w, min_h, max_d)
)
self._grid_mesh = mb.getData()
for n in range(0, 6):
@ -128,10 +128,10 @@ class BuildVolume(SceneNode):
color = Color(0.0, 0.0, 0.0, 0.15)
for polygon in self._disallowed_areas:
points = polygon.getPoints()
first = Vector(self._clamp(points[0][0], minW, maxW), disallowed_area_height, self._clamp(points[0][1], minD, maxD))
previous_point = Vector(self._clamp(points[0][0], minW, maxW), disallowed_area_height, self._clamp(points[0][1], minD, maxD))
first = Vector(self._clamp(points[0][0], min_w, max_w), disallowed_area_height, self._clamp(points[0][1], min_d, max_d))
previous_point = Vector(self._clamp(points[0][0], min_w, max_w), disallowed_area_height, self._clamp(points[0][1], min_d, max_d))
for point in points:
new_point = Vector(self._clamp(point[0], minW, maxW), disallowed_area_height, self._clamp(point[1], minD, maxD))
new_point = Vector(self._clamp(point[0], min_w, max_w), disallowed_area_height, self._clamp(point[1], min_d, max_d))
mb.addFace(first, previous_point, new_point, color = color)
previous_point = new_point
@ -143,7 +143,7 @@ class BuildVolume(SceneNode):
else:
self._disallowed_area_mesh = None
self._aabb = AxisAlignedBox(minimum = Vector(minW, minH - 1.0, minD), maximum = Vector(maxW, maxH, maxD))
self._aabb = AxisAlignedBox(minimum = Vector(min_w, min_h - 1.0, min_d), maximum = Vector(max_w, max_h, max_d))
skirt_size = 0.0
@ -152,8 +152,8 @@ class BuildVolume(SceneNode):
skirt_size = self._getSkirtSize(profile)
scale_to_max_bounds = AxisAlignedBox(
minimum = Vector(minW + skirt_size, minH, minD + skirt_size + disallowed_area_size),
maximum = Vector(maxW - skirt_size, maxH, maxD - skirt_size - disallowed_area_size)
minimum = Vector(min_w + skirt_size, min_h, min_d + skirt_size + disallowed_area_size),
maximum = Vector(max_w - skirt_size, max_h, max_d - skirt_size - disallowed_area_size)
)
Application.getInstance().getController().getScene()._maximum_bounds = scale_to_max_bounds

View File

@ -29,7 +29,7 @@ class ConvexHullNode(SceneNode):
self._node.parentChanged.connect(self._onNodeParentChanged)
self._node.decoratorsChanged.connect(self._onNodeDecoratorsChanged)
self._onNodeDecoratorsChanged(self._node)
self.convexHullHeadMesh = None
self._convex_hull_head_mesh = None
self._hull = hull
hull_points = self._hull.getPoints()
@ -38,7 +38,7 @@ class ConvexHullNode(SceneNode):
self.setMeshData(hull_mesh)
convex_hull_head = self._node.callDecoration("getConvexHullHead")
if convex_hull_head:
self.convexHullHeadMesh = self.createHullMesh(convex_hull_head.getPoints())
self._convex_hull_head_mesh = self.createHullMesh(convex_hull_head.getPoints())
def createHullMesh(self, hull_points):
mesh = MeshData()
@ -68,8 +68,8 @@ class ConvexHullNode(SceneNode):
if self.getParent():
self._material.setUniformValue("u_color", self._color)
renderer.queueNode(self, material = self._material, transparent = True)
if self.convexHullHeadMesh:
renderer.queueNode(self, material = self._material,transparent = True, mesh = self.convexHullHeadMesh)
if self._convex_hull_head_mesh:
renderer.queueNode(self, material = self._material,transparent = True, mesh = self._convex_hull_head_mesh)
return True

View File

@ -3,11 +3,6 @@
import platform
if platform.system() == "Linux": # Needed for platform.linux_distribution, which is not available on Windows and OSX
# For Ubuntu: https://bugs.launchpad.net/ubuntu/+source/python-qt4/+bug/941826
if platform.linux_distribution()[0] in ("Ubuntu", ): # Just in case it also happens on Debian, so it can be added
from OpenGL import GL
from UM.Qt.QtApplication import QtApplication
from UM.Scene.SceneNode import SceneNode
from UM.Scene.Camera import Camera
@ -59,10 +54,15 @@ import numpy
import copy
numpy.seterr(all="ignore")
if platform.system() == "Linux": # Needed for platform.linux_distribution, which is not available on Windows and OSX
# For Ubuntu: https://bugs.launchpad.net/ubuntu/+source/python-qt4/+bug/941826
if platform.linux_distribution()[0] in ("Ubuntu", ): # Just in case it also happens on Debian, so it can be added
from OpenGL import GL
try:
from cura.CuraVersion import CuraVersion
except ImportError:
CuraVersion = "master"
CuraVersion = "master" # [CodeStyle: Reflecting imported value]
class CuraApplication(QtApplication):
class ResourceTypes:
@ -142,7 +142,7 @@ class CuraApplication(QtApplication):
parser.add_argument("--debug", dest="debug-mode", action="store_true", default=False, help="Enable detailed crash reports.")
def run(self):
if not "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" in os.environ or os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] != "cpp":
if "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" not in os.environ or os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] != "cpp":
Logger.log("w", "Using Python implementation of Protobuf, expect bad performance!")
self._i18n_catalog = i18nCatalog("cura");
@ -263,6 +263,7 @@ class CuraApplication(QtApplication):
self.jobNameChanged.emit()
jobNameChanged = pyqtSignal()
@pyqtProperty(str, notify = jobNameChanged)
def jobName(self):
return self._job_name
@ -427,6 +428,7 @@ class CuraApplication(QtApplication):
return log
recentFilesChanged = pyqtSignal()
@pyqtProperty("QVariantList", notify = recentFilesChanged)
def recentFiles(self):
return self._recent_files
@ -441,6 +443,7 @@ class CuraApplication(QtApplication):
self.expandedCategoriesChanged.emit()
expandedCategoriesChanged = pyqtSignal()
@pyqtProperty("QStringList", notify = expandedCategoriesChanged)
def expandedCategories(self):
return Preferences.getInstance().getValue("cura/categories_expanded").split(";")

View File

@ -45,7 +45,7 @@ class OneAtATimeIterator(Iterator.Iterator):
# This does not decrease the worst case running time, but should improve it in most cases.
sorted(node_list, key = cmp_to_key(self._calculateScore))
todo_node_list = [_objectOrder([], node_list)]
todo_node_list = [_ObjectOrder([], node_list)]
while len(todo_node_list) > 0:
current = todo_node_list.pop()
for node in current.todo:
@ -61,7 +61,7 @@ class OneAtATimeIterator(Iterator.Iterator):
self._node_stack = new_order
return
todo_node_list.append(_objectOrder(new_order, new_todo_list))
todo_node_list.append(_ObjectOrder(new_order, new_todo_list))
self._node_stack = [] #No result found!
@ -99,7 +99,7 @@ class OneAtATimeIterator(Iterator.Iterator):
## Internal object used to keep track of a possible order in which to print objects.
class _objectOrder():
class _ObjectOrder():
def __init__(self, order, todo):
"""
:param order: List of indexes in which to print objects, ordered by printing order.

View File

@ -19,7 +19,8 @@ except ImportError:
else:
os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "cpp"
import cura.CuraApplication
if True: # To make the code style checker stop complaining
import cura.CuraApplication
if sys.platform == "win32" and hasattr(sys, "frozen"):
import os

View File

@ -37,7 +37,7 @@ class ThreeMFReader(MeshReader):
if extension.lower() == self._supported_extension:
result = SceneNode()
# The base object of 3mf is a zipped archive.
archive = zipfile.ZipFile(file_name, 'r')
archive = zipfile.ZipFile(file_name, "r")
try:
root = ET.parse(archive.open("3D/3dmodel.model"))
@ -109,10 +109,10 @@ class ThreeMFReader(MeshReader):
node.setOrientation(temp_quaternion)
# Magical scale extraction
S2 = temp_mat.getTransposed().multiply(temp_mat)
scale_x = math.sqrt(S2.at(0,0))
scale_y = math.sqrt(S2.at(1,1))
scale_z = math.sqrt(S2.at(2,2))
scale = temp_mat.getTransposed().multiply(temp_mat)
scale_x = math.sqrt(scale.at(0,0))
scale_y = math.sqrt(scale.at(1,1))
scale_z = math.sqrt(scale.at(2,2))
node.setScale(Vector(scale_x,scale_y,scale_z))
# We use a different coordinate frame, so rotate.

View File

@ -1,11 +1,11 @@
# Copyright (c) 2015 Ultimaker B.V.
# Cura is released under the terms of the AGPLv3 or higher.
from . import ThreeMFReader
from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura")
from . import ThreeMFReader
def getMetaData():
return {
"plugin": {

View File

@ -58,7 +58,7 @@ class ChangeLog(Extension, QObject,):
def loadChangeLogs(self):
self._change_logs = collections.OrderedDict()
with open(os.path.join(PluginRegistry.getInstance().getPluginPath("ChangeLogPlugin"), "ChangeLog.txt"), 'r',-1, "utf-8") as f:
with open(os.path.join(PluginRegistry.getInstance().getPluginPath("ChangeLogPlugin"), "ChangeLog.txt"), "r",-1, "utf-8") as f:
open_version = None
open_header = None
for line in f:

View File

@ -125,7 +125,7 @@ class CuraEngineBackend(Backend):
return
if self._profile.hasErrorValue():
Logger.log('w', "Profile has error values. Aborting slicing")
Logger.log("w", "Profile has error values. Aborting slicing")
if self._message:
self._message.hide()
self._message = None

View File

@ -32,7 +32,7 @@ class ProcessSlicedObjectListJob(Job):
Application.getInstance().getController().activeViewChanged.connect(self._onActiveViewChanged)
objectIdMap = {}
object_id_map = {}
new_node = SceneNode()
## Put all nodes in a dict identified by ID
for node in DepthFirstIterator(self._scene.getRoot()):
@ -40,11 +40,10 @@ class ProcessSlicedObjectListJob(Job):
if node.callDecoration("getLayerData"):
self._scene.getRoot().removeChild(node)
else:
objectIdMap[id(node)] = node
object_id_map[id(node)] = node
Job.yieldThread()
settings = Application.getInstance().getMachineManager().getActiveProfile()
layerHeight = settings.getSettingValue("layer_height")
center = None
if not settings.getSettingValue("machine_center_is_zero"):
@ -62,7 +61,7 @@ class ProcessSlicedObjectListJob(Job):
current_layer = 0
for object in self._message.objects:
try:
node = objectIdMap[object.id]
node = object_id_map[object.id]
except KeyError:
continue

View File

@ -18,7 +18,7 @@ from . import Cura_pb2
## Formatter class that handles token expansion in start/end gcod
class GcodeStartEndFormatter(Formatter):
def get_value(self, key, args, kwargs):
def get_value(self, key, args, kwargs): # [CodeStyle: get_value is an overridden function from the Formatter class]
if isinstance(key, str):
try:
return kwargs[key]
@ -118,8 +118,8 @@ class StartSliceJob(Job):
msg = Cura_pb2.SettingList()
settings = profile.getAllSettingValues(include_machine = True)
start_gcode = settings["machine_start_gcode"]
settings["material_bed_temp_prepend"] = not "{material_bed_temperature}" in start_gcode
settings["material_print_temp_prepend"] = not "{material_print_temperature}" in start_gcode
settings["material_bed_temp_prepend"] = "{material_bed_temperature}" not in start_gcode
settings["material_print_temp_prepend"] = "{material_print_temperature}" not in start_gcode
for key, value in settings.items():
s = msg.settings.add()
s.name = key

View File

@ -1,11 +1,11 @@
# Copyright (c) 2015 Ultimaker B.V.
# Cura is released under the terms of the AGPLv3 or higher.
from . import GCodeReader
from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura")
from . import GCodeReader
def getMetaData():
return {
"plugin": {

View File

@ -1,6 +1,8 @@
from PyQt5.QtCore import QObject, pyqtSignal, pyqtSlot, pyqtProperty
from UM.Application import Application
import LayerView
class LayerViewProxy(QObject):
def __init__(self, parent = None):
super().__init__(parent)

View File

@ -20,17 +20,17 @@ catalog = i18nCatalog("cura")
# WinAPI Constants that we need
# Hardcoded here due to stupid WinDLL stuff that does not give us access to these values.
DRIVE_REMOVABLE = 2
DRIVE_REMOVABLE = 2 # [CodeStyle: Windows Enum value]
GENERIC_READ = 2147483648
GENERIC_WRITE = 1073741824
GENERIC_READ = 2147483648 # [CodeStyle: Windows Enum value]
GENERIC_WRITE = 1073741824 # [CodeStyle: Windows Enum value]
FILE_SHARE_READ = 1
FILE_SHARE_WRITE = 2
FILE_SHARE_READ = 1 # [CodeStyle: Windows Enum value]
FILE_SHARE_WRITE = 2 # [CodeStyle: Windows Enum value]
IOCTL_STORAGE_EJECT_MEDIA = 2967560
IOCTL_STORAGE_EJECT_MEDIA = 2967560 # [CodeStyle: Windows Enum value]
OPEN_EXISTING = 3
OPEN_EXISTING = 3 # [CodeStyle: Windows Enum value]
## Removable drive support for windows
class WindowsRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin):

View File

@ -110,7 +110,7 @@ class SliceInfo(Extension):
# Convert data to bytes
submitted_data = urllib.parse.urlencode(submitted_data)
binary_data = submitted_data.encode('utf-8')
binary_data = submitted_data.encode("utf-8")
# Submit data
try:

View File

@ -471,17 +471,17 @@ class PrinterConnection(OutputDevice, QObject, SignalEmitter):
self.showControlInterface()
def _setEndstopState(self, endstop_key, value):
if endstop_key == b'x_min':
if endstop_key == b"x_min":
if self._x_min_endstop_pressed != value:
self.endstopStateChanged.emit('x_min', value)
self.endstopStateChanged.emit("x_min", value)
self._x_min_endstop_pressed = value
elif endstop_key == b'y_min':
elif endstop_key == b"y_min":
if self._y_min_endstop_pressed != value:
self.endstopStateChanged.emit('y_min', value)
self.endstopStateChanged.emit("y_min", value)
self._y_min_endstop_pressed = value
elif endstop_key == b'z_min':
elif endstop_key == b"z_min":
if self._z_min_endstop_pressed != value:
self.endstopStateChanged.emit('z_min', value)
self.endstopStateChanged.emit("z_min", value)
self._z_min_endstop_pressed = value
## Listen thread function.
@ -528,8 +528,8 @@ class PrinterConnection(OutputDevice, QObject, SignalEmitter):
pass
#TODO: temperature changed callback
elif b"_min" in line or b"_max" in line:
tag, value = line.split(b':', 1)
self._setEndstopState(tag,(b'H' in value or b'TRIGGERED' in value))
tag, value = line.split(b":", 1)
self._setEndstopState(tag,(b"H" in value or b"TRIGGERED" in value))
if self._is_printing:
if line == b"" and time.time() > ok_timeout:

View File

@ -56,6 +56,7 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension):
printerConnectionStateChanged = pyqtSignal()
progressChanged = pyqtSignal()
@pyqtProperty(float, notify = progressChanged)
def progress(self):
progress = 0