mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-19 04:09:40 +08:00
Fix coding style issues
This commit is contained in:
parent
743b403b29
commit
9267b517d6
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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:
|
||||
@ -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(";")
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -1,9 +1,9 @@
|
||||
# Copyright (c) 2015 Ultimaker B.V.
|
||||
# Cura is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
from UM.i18n import i18nCatalog
|
||||
from . import ThreeMFReader
|
||||
|
||||
from UM.i18n import i18nCatalog
|
||||
catalog = i18nCatalog("cura")
|
||||
|
||||
def getMetaData():
|
||||
|
@ -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
|
||||
|
||||
|
@ -115,12 +115,17 @@ class StartSliceJob(Job):
|
||||
return str(value).encode("utf-8")
|
||||
|
||||
def _sendSettings(self, profile):
|
||||
Application.getInstance().getMachineManager().getActiveMachineInstance().setMachineSettingValue("machine_gcode_flavor", "RepRap")
|
||||
|
||||
msg = Cura_pb2.SettingList()
|
||||
settings = profile.getAllSettingValues(include_machine = True)
|
||||
start_gcode = settings["machine_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():
|
||||
if key == "machine_gcode_flavor":
|
||||
print("machine_gcode_flavor", value)
|
||||
|
||||
s = msg.settings.add()
|
||||
s.name = key
|
||||
if key == "machine_start_gcode" or key == "machine_end_gcode":
|
||||
|
@ -1,9 +1,9 @@
|
||||
# Copyright (c) 2015 Ultimaker B.V.
|
||||
# Cura is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
from UM.i18n import i18nCatalog
|
||||
from . import GCodeReader
|
||||
|
||||
from UM.i18n import i18nCatalog
|
||||
catalog = i18nCatalog("cura")
|
||||
|
||||
def getMetaData():
|
||||
|
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user