mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-17 16:36:40 +08:00
Merge pull request #666 from thopiekar/master-code-fixes
Fixing small issues in the code (#2)
This commit is contained in:
commit
14f5d236b2
@ -33,7 +33,7 @@ class ConvexHullNode(SceneNode):
|
|||||||
self._convex_hull_head_mesh = None
|
self._convex_hull_head_mesh = None
|
||||||
self._hull = hull
|
self._hull = hull
|
||||||
|
|
||||||
hull_points = self._hull.getPoints()
|
hull_points = self._hull.getPoints() # TODO: @UnusedVariable
|
||||||
hull_mesh = self.createHullMesh(self._hull.getPoints())
|
hull_mesh = self.createHullMesh(self._hull.getPoints())
|
||||||
if hull_mesh:
|
if hull_mesh:
|
||||||
self.setMeshData(hull_mesh)
|
self.setMeshData(hull_mesh)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty, QUrl
|
from PyQt5.QtCore import QObject, pyqtSlot, QUrl
|
||||||
from PyQt5.QtGui import QDesktopServices
|
from PyQt5.QtGui import QDesktopServices
|
||||||
|
|
||||||
from UM.Event import CallFunctionEvent
|
from UM.Event import CallFunctionEvent
|
||||||
|
@ -6,22 +6,16 @@ from UM.Scene.SceneNode import SceneNode
|
|||||||
from UM.Scene.Camera import Camera
|
from UM.Scene.Camera import Camera
|
||||||
from UM.Scene.Platform import Platform
|
from UM.Scene.Platform import Platform
|
||||||
from UM.Math.Vector import Vector
|
from UM.Math.Vector import Vector
|
||||||
from UM.Math.Matrix import Matrix
|
|
||||||
from UM.Math.Quaternion import Quaternion
|
from UM.Math.Quaternion import Quaternion
|
||||||
from UM.Math.AxisAlignedBox import AxisAlignedBox
|
from UM.Math.AxisAlignedBox import AxisAlignedBox
|
||||||
from UM.Resources import Resources
|
from UM.Resources import Resources
|
||||||
from UM.Scene.ToolHandle import ToolHandle
|
from UM.Scene.ToolHandle import ToolHandle
|
||||||
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
||||||
from UM.Mesh.WriteMeshJob import WriteMeshJob
|
|
||||||
from UM.Mesh.ReadMeshJob import ReadMeshJob
|
from UM.Mesh.ReadMeshJob import ReadMeshJob
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from UM.Preferences import Preferences
|
from UM.Preferences import Preferences
|
||||||
from UM.Message import Message
|
|
||||||
from UM.PluginRegistry import PluginRegistry
|
|
||||||
from UM.JobQueue import JobQueue
|
from UM.JobQueue import JobQueue
|
||||||
from UM.Math.Polygon import Polygon
|
|
||||||
|
|
||||||
from UM.Scene.BoxRenderer import BoxRenderer
|
|
||||||
from UM.Scene.Selection import Selection
|
from UM.Scene.Selection import Selection
|
||||||
from UM.Scene.GroupDecorator import GroupDecorator
|
from UM.Scene.GroupDecorator import GroupDecorator
|
||||||
|
|
||||||
@ -41,7 +35,7 @@ from . import MultiMaterialDecorator
|
|||||||
from . import ZOffsetDecorator
|
from . import ZOffsetDecorator
|
||||||
from . import CuraSplashScreen
|
from . import CuraSplashScreen
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtSlot, QUrl, Qt, pyqtSignal, pyqtProperty, QEvent, Q_ENUMS
|
from PyQt5.QtCore import pyqtSlot, QUrl, pyqtSignal, pyqtProperty, QEvent, Q_ENUMS
|
||||||
from PyQt5.QtGui import QColor, QIcon
|
from PyQt5.QtGui import QColor, QIcon
|
||||||
from PyQt5.QtQml import qmlRegisterUncreatableType
|
from PyQt5.QtQml import qmlRegisterUncreatableType
|
||||||
|
|
||||||
@ -353,7 +347,7 @@ class CuraApplication(QtApplication):
|
|||||||
|
|
||||||
if node:
|
if node:
|
||||||
op = GroupedOperation()
|
op = GroupedOperation()
|
||||||
for i in range(count):
|
for _ in range(count):
|
||||||
if node.getParent() and node.getParent().callDecoration("isGroup"):
|
if node.getParent() and node.getParent().callDecoration("isGroup"):
|
||||||
new_node = copy.deepcopy(node.getParent()) #Copy the group node.
|
new_node = copy.deepcopy(node.getParent()) #Copy the group node.
|
||||||
new_node.callDecoration("setConvexHull",None)
|
new_node.callDecoration("setConvexHull",None)
|
||||||
@ -528,6 +522,7 @@ class CuraApplication(QtApplication):
|
|||||||
try:
|
try:
|
||||||
group_node = Selection.getAllSelectedObjects()[0]
|
group_node = Selection.getAllSelectedObjects()[0]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Logger.log("d", "mergeSelected: Exception:", e)
|
||||||
return
|
return
|
||||||
multi_material_decorator = MultiMaterialDecorator.MultiMaterialDecorator()
|
multi_material_decorator = MultiMaterialDecorator.MultiMaterialDecorator()
|
||||||
group_node.addDecorator(multi_material_decorator)
|
group_node.addDecorator(multi_material_decorator)
|
||||||
|
@ -7,8 +7,6 @@ from UM.Math.Color import Color
|
|||||||
from UM.Math.Vector import Vector
|
from UM.Math.Vector import Vector
|
||||||
|
|
||||||
import numpy
|
import numpy
|
||||||
import math
|
|
||||||
import copy
|
|
||||||
|
|
||||||
class LayerData(MeshData):
|
class LayerData(MeshData):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -20,11 +18,11 @@ class LayerData(MeshData):
|
|||||||
if layer not in self._layers:
|
if layer not in self._layers:
|
||||||
self._layers[layer] = Layer(layer)
|
self._layers[layer] = Layer(layer)
|
||||||
|
|
||||||
def addPolygon(self, layer, type, data, line_width):
|
def addPolygon(self, layer, polygon_type, data, line_width):
|
||||||
if layer not in self._layers:
|
if layer not in self._layers:
|
||||||
self.addLayer(layer)
|
self.addLayer(layer)
|
||||||
|
|
||||||
p = Polygon(self, type, data, line_width)
|
p = Polygon(self, polygon_type, data, line_width)
|
||||||
self._layers[layer].polygons.append(p)
|
self._layers[layer].polygons.append(p)
|
||||||
|
|
||||||
def getLayer(self, layer):
|
def getLayer(self, layer):
|
||||||
@ -69,8 +67,8 @@ class LayerData(MeshData):
|
|||||||
self.addIndices(indices.flatten())
|
self.addIndices(indices.flatten())
|
||||||
|
|
||||||
class Layer():
|
class Layer():
|
||||||
def __init__(self, id):
|
def __init__(self, layer_id):
|
||||||
self._id = id
|
self._id = layer_id
|
||||||
self._height = 0.0
|
self._height = 0.0
|
||||||
self._thickness = 0.0
|
self._thickness = 0.0
|
||||||
self._polygons = []
|
self._polygons = []
|
||||||
@ -173,9 +171,9 @@ class Polygon():
|
|||||||
MoveCombingType = 8
|
MoveCombingType = 8
|
||||||
MoveRetractionType = 9
|
MoveRetractionType = 9
|
||||||
|
|
||||||
def __init__(self, mesh, type, data, line_width):
|
def __init__(self, mesh, polygon_type, data, line_width):
|
||||||
self._mesh = mesh
|
self._mesh = mesh
|
||||||
self._type = type
|
self._type = polygon_type
|
||||||
self._data = data
|
self._data = data
|
||||||
self._line_width = line_width / 1000
|
self._line_width = line_width / 1000
|
||||||
|
|
||||||
|
@ -5,8 +5,6 @@ from PyQt5.QtCore import QTimer
|
|||||||
|
|
||||||
from UM.Scene.SceneNode import SceneNode
|
from UM.Scene.SceneNode import SceneNode
|
||||||
from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator
|
from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator
|
||||||
from UM.Operations.TranslateOperation import TranslateOperation
|
|
||||||
from UM.Math.Float import Float
|
|
||||||
from UM.Math.Vector import Vector
|
from UM.Math.Vector import Vector
|
||||||
from UM.Math.AxisAlignedBox import AxisAlignedBox
|
from UM.Math.AxisAlignedBox import AxisAlignedBox
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
# Cura is released under the terms of the AGPLv3 or higher.
|
# Cura is released under the terms of the AGPLv3 or higher.
|
||||||
|
|
||||||
from UM.Operations.Operation import Operation
|
from UM.Operations.Operation import Operation
|
||||||
from UM.Operations.AddSceneNodeOperation import AddSceneNodeOperation
|
|
||||||
from UM.Operations.TranslateOperation import TranslateOperation
|
|
||||||
from UM.Operations.GroupedOperation import GroupedOperation
|
from UM.Operations.GroupedOperation import GroupedOperation
|
||||||
|
|
||||||
## A specialised operation designed specifically to modify the previous operation.
|
## A specialised operation designed specifically to modify the previous operation.
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
# Copyright (c) 2015 Ultimaker B.V.
|
# Copyright (c) 2015 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the AGPLv3 or higher.
|
# Cura is released under the terms of the AGPLv3 or higher.
|
||||||
|
|
||||||
from PyQt5.QtCore import QObject, QDateTime, QTimer, pyqtSignal, pyqtSlot, pyqtProperty
|
from PyQt5.QtCore import QObject, pyqtSignal, pyqtProperty
|
||||||
|
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
from UM.Resources import Resources
|
|
||||||
from UM.Scene.SceneNode import SceneNode
|
|
||||||
from UM.Qt.Duration import Duration
|
from UM.Qt.Duration import Duration
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
@ -42,7 +42,7 @@ class ChangeLog(Extension, QObject,):
|
|||||||
@pyqtSlot(result = str)
|
@pyqtSlot(result = str)
|
||||||
def getChangeLogString(self):
|
def getChangeLogString(self):
|
||||||
logs = self.getChangeLogs()
|
logs = self.getChangeLogs()
|
||||||
latest_version = Version(Preferences.getInstance().getValue("general/latest_version_changelog_shown"))
|
latest_version = Version(Preferences.getInstance().getValue("general/latest_version_changelog_shown")) #TODO: @UnusedVariable
|
||||||
result = ""
|
result = ""
|
||||||
for version in logs:
|
for version in logs:
|
||||||
result += "<h1>" + str(version) + "</h1><br>"
|
result += "<h1>" + str(version) + "</h1><br>"
|
||||||
|
@ -4,25 +4,19 @@
|
|||||||
from UM.Backend.Backend import Backend
|
from UM.Backend.Backend import Backend
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
from UM.Scene.SceneNode import SceneNode
|
from UM.Scene.SceneNode import SceneNode
|
||||||
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
|
||||||
from UM.Preferences import Preferences
|
from UM.Preferences import Preferences
|
||||||
from UM.Math.Vector import Vector
|
|
||||||
from UM.Signal import Signal
|
from UM.Signal import Signal
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from UM.Qt.Bindings.BackendProxy import BackendState #To determine the state of the slicing job.
|
from UM.Qt.Bindings.BackendProxy import BackendState #To determine the state of the slicing job.
|
||||||
from UM.Resources import Resources
|
|
||||||
from UM.Settings.SettingOverrideDecorator import SettingOverrideDecorator
|
|
||||||
from UM.Message import Message
|
from UM.Message import Message
|
||||||
from UM.PluginRegistry import PluginRegistry
|
from UM.PluginRegistry import PluginRegistry
|
||||||
|
|
||||||
from cura.OneAtATimeIterator import OneAtATimeIterator
|
|
||||||
from . import ProcessSlicedObjectListJob
|
from . import ProcessSlicedObjectListJob
|
||||||
from . import ProcessGCodeJob
|
from . import ProcessGCodeJob
|
||||||
from . import StartSliceJob
|
from . import StartSliceJob
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import numpy
|
|
||||||
|
|
||||||
from PyQt5.QtCore import QTimer
|
from PyQt5.QtCore import QTimer
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ from cura import LayerData
|
|||||||
from cura import LayerDataDecorator
|
from cura import LayerDataDecorator
|
||||||
|
|
||||||
import numpy
|
import numpy
|
||||||
import struct
|
|
||||||
|
|
||||||
catalog = i18nCatalog("cura")
|
catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
@ -51,7 +50,7 @@ class ProcessSlicedObjectListJob(Job):
|
|||||||
|
|
||||||
object_id_map = {}
|
object_id_map = {}
|
||||||
new_node = SceneNode()
|
new_node = SceneNode()
|
||||||
## Put all nodes in a dict identified by ID
|
## Put all nodes in a dictionary identified by ID
|
||||||
for node in DepthFirstIterator(self._scene.getRoot()):
|
for node in DepthFirstIterator(self._scene.getRoot()):
|
||||||
if type(node) is SceneNode and node.getMeshData():
|
if type(node) is SceneNode and node.getMeshData():
|
||||||
if node.callDecoration("getLayerData"):
|
if node.callDecoration("getLayerData"):
|
||||||
@ -74,15 +73,15 @@ class ProcessSlicedObjectListJob(Job):
|
|||||||
layer_count += self._message.getRepeatedMessage("objects", i).repeatedMessageCount("layers")
|
layer_count += self._message.getRepeatedMessage("objects", i).repeatedMessageCount("layers")
|
||||||
|
|
||||||
current_layer = 0
|
current_layer = 0
|
||||||
for i in range(self._message.repeatedMessageCount("objects")):
|
for object_position in range(self._message.repeatedMessageCount("objects")):
|
||||||
object = self._message.getRepeatedMessage("objects", i)
|
current_object = self._message.getRepeatedMessage("objects", object_position)
|
||||||
try:
|
try:
|
||||||
node = object_id_map[object.id]
|
node = object_id_map[current_object.id]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for l in range(object.repeatedMessageCount("layers")):
|
for l in range(current_object.repeatedMessageCount("layers")):
|
||||||
layer = object.getRepeatedMessage("layers", l)
|
layer = current_object.getRepeatedMessage("layers", l)
|
||||||
|
|
||||||
layer_data.addLayer(layer.id)
|
layer_data.addLayer(layer.id)
|
||||||
layer_data.setLayerHeight(layer.id, layer.height)
|
layer_data.setLayerHeight(layer.id, layer.height)
|
||||||
|
@ -87,11 +87,11 @@ class StartSliceJob(Job):
|
|||||||
group_message = slice_message.addRepeatedMessage("object_lists")
|
group_message = slice_message.addRepeatedMessage("object_lists")
|
||||||
if group[0].getParent().callDecoration("isGroup"):
|
if group[0].getParent().callDecoration("isGroup"):
|
||||||
self._handlePerObjectSettings(group[0].getParent(), group_message)
|
self._handlePerObjectSettings(group[0].getParent(), group_message)
|
||||||
for object in group:
|
for current_object in group:
|
||||||
mesh_data = object.getMeshData().getTransformed(object.getWorldTransformation())
|
mesh_data = current_object.getMeshData().getTransformed(current_object.getWorldTransformation())
|
||||||
|
|
||||||
obj = group_message.addRepeatedMessage("objects")
|
obj = group_message.addRepeatedMessage("objects")
|
||||||
obj.id = id(object)
|
obj.id = id(current_object)
|
||||||
|
|
||||||
verts = numpy.array(mesh_data.getVertices())
|
verts = numpy.array(mesh_data.getVertices())
|
||||||
verts[:,[1,2]] = verts[:,[2,1]]
|
verts[:,[1,2]] = verts[:,[2,1]]
|
||||||
@ -99,7 +99,7 @@ class StartSliceJob(Job):
|
|||||||
|
|
||||||
obj.vertices = verts
|
obj.vertices = verts
|
||||||
|
|
||||||
self._handlePerObjectSettings(object, obj)
|
self._handlePerObjectSettings(current_object, obj)
|
||||||
|
|
||||||
Job.yieldThread()
|
Job.yieldThread()
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# Cura is released under the terms of the AGPLv3 or higher.
|
# Cura is released under the terms of the AGPLv3 or higher.
|
||||||
|
|
||||||
from UM.Application import Application #To get the machine manager to create the new profile in.
|
from UM.Application import Application #To get the machine manager to create the new profile in.
|
||||||
|
from UM.Logger import Logger
|
||||||
from UM.Settings.Profile import Profile
|
from UM.Settings.Profile import Profile
|
||||||
from UM.Settings.ProfileReader import ProfileReader
|
from UM.Settings.ProfileReader import ProfileReader
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from UM.SaveFile import SaveFile
|
from UM.SaveFile import SaveFile
|
||||||
from UM.Settings.Profile import Profile
|
|
||||||
from UM.Settings.ProfileWriter import ProfileWriter
|
from UM.Settings.ProfileWriter import ProfileWriter
|
||||||
|
|
||||||
## Writes profiles to Cura's own profile format with config files.
|
## Writes profiles to Cura's own profile format with config files.
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
from UM.Mesh.MeshWriter import MeshWriter
|
from UM.Mesh.MeshWriter import MeshWriter
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
import io
|
|
||||||
import re #For escaping characters in the settings.
|
import re #For escaping characters in the settings.
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
# Copyright (c) 2015 Ultimaker B.V.
|
# Copyright (c) 2015 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the AGPLv3 or higher.
|
# Cura is released under the terms of the AGPLv3 or higher.
|
||||||
|
|
||||||
import os
|
|
||||||
import numpy
|
import numpy
|
||||||
|
|
||||||
from PyQt5.QtGui import QImage, qRed, qGreen, qBlue
|
from PyQt5.QtGui import QImage, qRed, qGreen, qBlue
|
||||||
@ -49,8 +48,8 @@ class ImageReader(MeshReader):
|
|||||||
return self._generateSceneNode(file_name, size, self._ui.peak_height, self._ui.base_height, self._ui.smoothing, 512, self._ui.image_color_invert)
|
return self._generateSceneNode(file_name, size, self._ui.peak_height, self._ui.base_height, self._ui.smoothing, 512, self._ui.image_color_invert)
|
||||||
|
|
||||||
def _generateSceneNode(self, file_name, xz_size, peak_height, base_height, blur_iterations, max_size, image_color_invert):
|
def _generateSceneNode(self, file_name, xz_size, peak_height, base_height, blur_iterations, max_size, image_color_invert):
|
||||||
mesh = None
|
mesh = None # TODO: @UnusedVariable
|
||||||
scene_node = None
|
scene_node = None # TODO: @UnusedVariable
|
||||||
|
|
||||||
scene_node = SceneNode()
|
scene_node = SceneNode()
|
||||||
|
|
||||||
@ -111,7 +110,7 @@ class ImageReader(MeshReader):
|
|||||||
if image_color_invert:
|
if image_color_invert:
|
||||||
height_data = 1 - height_data
|
height_data = 1 - height_data
|
||||||
|
|
||||||
for i in range(0, blur_iterations):
|
for _ in range(0, blur_iterations):
|
||||||
copy = numpy.pad(height_data, ((1, 1), (1, 1)), mode= "edge")
|
copy = numpy.pad(height_data, ((1, 1), (1, 1)), mode= "edge")
|
||||||
|
|
||||||
height_data += copy[1:-1, 2:]
|
height_data += copy[1:-1, 2:]
|
||||||
|
@ -136,7 +136,7 @@ class LayerView(View):
|
|||||||
|
|
||||||
def calculateMaxLayers(self):
|
def calculateMaxLayers(self):
|
||||||
scene = self.getController().getScene()
|
scene = self.getController().getScene()
|
||||||
renderer = self.getRenderer() # TODO: Unused variable
|
renderer = self.getRenderer() # TODO: @UnusedVariable
|
||||||
self._activity = True
|
self._activity = True
|
||||||
|
|
||||||
self._old_max_layers = self._max_layers
|
self._old_max_layers = self._max_layers
|
||||||
|
@ -58,7 +58,7 @@ class OSXRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin):
|
|||||||
if type(t) is dict:
|
if type(t) is dict:
|
||||||
if "_name" in t and t["_name"] == n:
|
if "_name" in t and t["_name"] == n:
|
||||||
ret.append(t)
|
ret.append(t)
|
||||||
for k, v in t.items():
|
for k, v in t.items(): # TODO: @UnusedVariable "k"
|
||||||
ret += self._findInTree(v, n)
|
ret += self._findInTree(v, n)
|
||||||
if type(t) is list:
|
if type(t) is list:
|
||||||
for v in t:
|
for v in t:
|
||||||
|
@ -8,7 +8,6 @@ from UM.Mesh.MeshWriter import MeshWriter
|
|||||||
from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator
|
from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator
|
||||||
from UM.OutputDevice.OutputDevice import OutputDevice
|
from UM.OutputDevice.OutputDevice import OutputDevice
|
||||||
from UM.OutputDevice import OutputDeviceError
|
from UM.OutputDevice import OutputDeviceError
|
||||||
from UM.Preferences import Preferences
|
|
||||||
|
|
||||||
from UM.i18n import i18nCatalog
|
from UM.i18n import i18nCatalog
|
||||||
catalog = i18nCatalog("cura")
|
catalog = i18nCatalog("cura")
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from UM.Signal import Signal
|
|
||||||
from UM.Message import Message
|
from UM.Message import Message
|
||||||
from UM.OutputDevice.OutputDevicePlugin import OutputDevicePlugin
|
from UM.OutputDevice.OutputDevicePlugin import OutputDevicePlugin
|
||||||
|
|
||||||
|
@ -2,22 +2,14 @@
|
|||||||
# Copyright (c) 2013 David Braam
|
# Copyright (c) 2013 David Braam
|
||||||
# Uranium is released under the terms of the AGPLv3 or higher.
|
# Uranium is released under the terms of the AGPLv3 or higher.
|
||||||
|
|
||||||
from . import RemovableDrivePlugin
|
|
||||||
|
|
||||||
import threading
|
|
||||||
import string
|
|
||||||
|
|
||||||
from ctypes import windll
|
|
||||||
from ctypes import wintypes
|
|
||||||
|
|
||||||
import ctypes
|
|
||||||
import time
|
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
from UM.i18n import i18nCatalog
|
from UM.i18n import i18nCatalog
|
||||||
catalog = i18nCatalog("cura")
|
catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
|
from . import RemovableDrivePlugin
|
||||||
|
|
||||||
|
import string
|
||||||
|
import ctypes
|
||||||
|
|
||||||
# WinAPI Constants that we need
|
# WinAPI Constants that we need
|
||||||
# Hardcoded here due to stupid WinDLL stuff that does not give us access to these values.
|
# Hardcoded here due to stupid WinDLL stuff that does not give us access to these values.
|
||||||
DRIVE_REMOVABLE = 2 # [CodeStyle: Windows Enum value]
|
DRIVE_REMOVABLE = 2 # [CodeStyle: Windows Enum value]
|
||||||
@ -37,7 +29,7 @@ class WindowsRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin):
|
|||||||
def checkRemovableDrives(self):
|
def checkRemovableDrives(self):
|
||||||
drives = {}
|
drives = {}
|
||||||
|
|
||||||
bitmask = windll.kernel32.GetLogicalDrives()
|
bitmask = ctypes.windll.kernel32.GetLogicalDrives()
|
||||||
# Check possible drive letters, from A to Z
|
# Check possible drive letters, from A to Z
|
||||||
# Note: using ascii_uppercase because we do not want this to change with locale!
|
# Note: using ascii_uppercase because we do not want this to change with locale!
|
||||||
for letter in string.ascii_uppercase:
|
for letter in string.ascii_uppercase:
|
||||||
@ -45,11 +37,11 @@ class WindowsRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin):
|
|||||||
|
|
||||||
# Do we really want to skip A and B?
|
# Do we really want to skip A and B?
|
||||||
# GetDriveTypeA explicitly wants a byte array of type ascii. It will accept a string, but this wont work
|
# GetDriveTypeA explicitly wants a byte array of type ascii. It will accept a string, but this wont work
|
||||||
if bitmask & 1 and windll.kernel32.GetDriveTypeA(drive.encode("ascii")) == DRIVE_REMOVABLE:
|
if bitmask & 1 and ctypes.windll.kernel32.GetDriveTypeA(drive.encode("ascii")) == DRIVE_REMOVABLE:
|
||||||
volume_name = ""
|
volume_name = ""
|
||||||
name_buffer = ctypes.create_unicode_buffer(1024)
|
name_buffer = ctypes.create_unicode_buffer(1024)
|
||||||
filesystem_buffer = ctypes.create_unicode_buffer(1024)
|
filesystem_buffer = ctypes.create_unicode_buffer(1024)
|
||||||
error = windll.kernel32.GetVolumeInformationW(ctypes.c_wchar_p(drive), name_buffer, ctypes.sizeof(name_buffer), None, None, None, filesystem_buffer, ctypes.sizeof(filesystem_buffer))
|
error = ctypes.windll.kernel32.GetVolumeInformationW(ctypes.c_wchar_p(drive), name_buffer, ctypes.sizeof(name_buffer), None, None, None, filesystem_buffer, ctypes.sizeof(filesystem_buffer))
|
||||||
|
|
||||||
if error != 0:
|
if error != 0:
|
||||||
volume_name = name_buffer.value
|
volume_name = name_buffer.value
|
||||||
@ -66,7 +58,7 @@ class WindowsRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin):
|
|||||||
|
|
||||||
# Check for the free space. Some card readers show up as a drive with 0 space free when there is no card inserted.
|
# Check for the free space. Some card readers show up as a drive with 0 space free when there is no card inserted.
|
||||||
free_bytes = ctypes.c_longlong(0)
|
free_bytes = ctypes.c_longlong(0)
|
||||||
if windll.kernel32.GetDiskFreeSpaceExA(drive.encode("ascii"), ctypes.byref(free_bytes), None, None) == 0:
|
if ctypes.windll.kernel32.GetDiskFreeSpaceExA(drive.encode("ascii"), ctypes.byref(free_bytes), None, None) == 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if free_bytes.value < 1:
|
if free_bytes.value < 1:
|
||||||
@ -80,19 +72,19 @@ class WindowsRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin):
|
|||||||
def performEjectDevice(self, device):
|
def performEjectDevice(self, device):
|
||||||
# Magic WinAPI stuff
|
# Magic WinAPI stuff
|
||||||
# First, open a handle to the Device
|
# First, open a handle to the Device
|
||||||
handle = windll.kernel32.CreateFileA("\\\\.\\{0}".format(device.getId()[:-1]).encode("ascii"), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, None, OPEN_EXISTING, 0, None )
|
handle = ctypes.windll.kernel32.CreateFileA("\\\\.\\{0}".format(device.getId()[:-1]).encode("ascii"), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, None, OPEN_EXISTING, 0, None )
|
||||||
|
|
||||||
if handle == -1:
|
if handle == -1:
|
||||||
print(windll.kernel32.GetLastError())
|
print(ctypes.windll.kernel32.GetLastError())
|
||||||
return
|
return
|
||||||
|
|
||||||
result = None
|
result = None
|
||||||
# Then, try and tell it to eject
|
# Then, try and tell it to eject
|
||||||
if not windll.kernel32.DeviceIoControl(handle, IOCTL_STORAGE_EJECT_MEDIA, None, None, None, None, None, None):
|
if not ctypes.windll.kernel32.DeviceIoControl(handle, IOCTL_STORAGE_EJECT_MEDIA, None, None, None, None, None, None):
|
||||||
result = False
|
result = False
|
||||||
else:
|
else:
|
||||||
result = True
|
result = True
|
||||||
|
|
||||||
# Finally, close the handle
|
# Finally, close the handle
|
||||||
windll.kernel32.CloseHandle(handle)
|
ctypes.windll.kernel32.CloseHandle(handle)
|
||||||
return result
|
return result
|
||||||
|
@ -66,7 +66,7 @@ class SliceInfo(Extension):
|
|||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
profile_values = settings.getChangedSettings() # TODO: Unused variable
|
profile_values = settings.getChangedSettings() # TODO: @UnusedVariable
|
||||||
|
|
||||||
# Get total material used (in mm^3)
|
# Get total material used (in mm^3)
|
||||||
print_information = Application.getInstance().getPrintInformation()
|
print_information = Application.getInstance().getPrintInformation()
|
||||||
|
@ -5,7 +5,6 @@ from UM.View.View import View
|
|||||||
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
||||||
from UM.Resources import Resources
|
from UM.Resources import Resources
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
from UM.Math.Color import Color
|
|
||||||
from UM.Preferences import Preferences
|
from UM.Preferences import Preferences
|
||||||
from UM.View.Renderer import Renderer
|
from UM.View.Renderer import Renderer
|
||||||
|
|
||||||
|
@ -12,10 +12,8 @@ import os.path
|
|||||||
|
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
from UM.Signal import Signal, SignalEmitter
|
from UM.Signal import Signal, SignalEmitter
|
||||||
from UM.Resources import Resources
|
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from UM.OutputDevice.OutputDevice import OutputDevice
|
from UM.OutputDevice.OutputDevice import OutputDevice
|
||||||
from UM.OutputDevice import OutputDeviceError
|
|
||||||
from UM.PluginRegistry import PluginRegistry
|
from UM.PluginRegistry import PluginRegistry
|
||||||
|
|
||||||
from PyQt5.QtQuick import QQuickView
|
from PyQt5.QtQuick import QQuickView
|
||||||
@ -337,6 +335,7 @@ class PrinterConnection(OutputDevice, QObject, SignalEmitter):
|
|||||||
try:
|
try:
|
||||||
self._connect_thread.join()
|
self._connect_thread.join()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Logger.log("d", "PrinterConnection.close: %s (expected)", e)
|
||||||
pass # This should work, but it does fail sometimes for some reason
|
pass # This should work, but it does fail sometimes for some reason
|
||||||
|
|
||||||
self._connect_thread = threading.Thread(target=self._connect)
|
self._connect_thread = threading.Thread(target=self._connect)
|
||||||
@ -457,6 +456,7 @@ class PrinterConnection(OutputDevice, QObject, SignalEmitter):
|
|||||||
self._extruder_temperatures[index] = temperature
|
self._extruder_temperatures[index] = temperature
|
||||||
self.extruderTemperatureChanged.emit()
|
self.extruderTemperatureChanged.emit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Logger.log("d", "PrinterConnection._setExtruderTemperature: ", e)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
## Private function to set the temperature of the bed.
|
## Private function to set the temperature of the bed.
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
from UM.Signal import Signal, SignalEmitter
|
from UM.Signal import Signal, SignalEmitter
|
||||||
from . import PrinterConnection
|
from . import PrinterConnection
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
|
||||||
from UM.Scene.SceneNode import SceneNode
|
|
||||||
from UM.Resources import Resources
|
from UM.Resources import Resources
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from UM.PluginRegistry import PluginRegistry
|
from UM.PluginRegistry import PluginRegistry
|
||||||
@ -20,7 +18,6 @@ import platform
|
|||||||
import glob
|
import glob
|
||||||
import time
|
import time
|
||||||
import os.path
|
import os.path
|
||||||
import sys
|
|
||||||
from UM.Extension import Extension
|
from UM.Extension import Extension
|
||||||
|
|
||||||
from PyQt5.QtQuick import QQuickView
|
from PyQt5.QtQuick import QQuickView
|
||||||
@ -59,7 +56,7 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension):
|
|||||||
@pyqtProperty(float, notify = progressChanged)
|
@pyqtProperty(float, notify = progressChanged)
|
||||||
def progress(self):
|
def progress(self):
|
||||||
progress = 0
|
progress = 0
|
||||||
for printer_name, connection in self._printer_connections.items():
|
for printer_name, connection in self._printer_connections.items(): # TODO: @UnusedVariable "printer_name"
|
||||||
progress += connection.progress
|
progress += connection.progress
|
||||||
|
|
||||||
return progress / len(self._printer_connections)
|
return progress / len(self._printer_connections)
|
||||||
@ -231,6 +228,7 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension):
|
|||||||
base_list += [values[1]]
|
base_list += [values[1]]
|
||||||
i += 1
|
i += 1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Logger.log("d", "USBPrinterManager.getSerialPortList: ", e)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if only_list_usb:
|
if only_list_usb:
|
||||||
|
5
setup.py
5
setup.py
@ -4,10 +4,9 @@
|
|||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
import py2exe
|
import py2exe
|
||||||
import UM
|
import UM
|
||||||
import UM.Qt
|
import UM.Qt #@UnusedImport
|
||||||
import cura
|
import cura #@UnusedImport
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
import shutil
|
import shutil
|
||||||
import site
|
import site
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user