mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 15:37:27 -06:00
Merge pull request #665 from thopiekar/master-code-fixes
Fixing small issues in the code
This commit is contained in:
commit
e4effc1236
16 changed files with 25 additions and 45 deletions
|
@ -1,11 +1,9 @@
|
|||
# Copyright (c) 2015 Ultimaker B.V.
|
||||
# Cura is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
from UM.View.Renderer import Renderer
|
||||
from UM.Scene.SceneNode import SceneNode
|
||||
from UM.Application import Application
|
||||
from UM.Resources import Resources
|
||||
from UM.Mesh.MeshData import MeshData
|
||||
from UM.Mesh.MeshBuilder import MeshBuilder
|
||||
from UM.Math.Vector import Vector
|
||||
from UM.Math.Color import Color
|
||||
|
|
|
@ -9,8 +9,6 @@ from UM.Mesh.MeshBuilder import MeshBuilder #To create a mesh to display the con
|
|||
|
||||
from UM.View.GL.OpenGL import OpenGL
|
||||
|
||||
import numpy
|
||||
|
||||
class ConvexHullNode(SceneNode):
|
||||
def __init__(self, node, hull, parent = None):
|
||||
super().__init__(parent)
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
from PyQt5.QtCore import QObject, pyqtSignal, pyqtSlot, pyqtProperty, QUrl
|
||||
from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty, QUrl
|
||||
from PyQt5.QtGui import QDesktopServices
|
||||
|
||||
from UM.Event import CallFunctionEvent
|
||||
from UM.Application import Application
|
||||
|
||||
import webbrowser
|
||||
|
||||
class CuraActions(QObject):
|
||||
def __init__(self, parent = None):
|
||||
super().__init__(parent)
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
# Copyright (c) 2015 Ultimaker B.V.
|
||||
# Cura is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
import platform
|
||||
|
||||
from UM.Qt.QtApplication import QtApplication
|
||||
from UM.Scene.SceneNode import SceneNode
|
||||
from UM.Scene.Camera import Camera
|
||||
|
@ -49,7 +47,6 @@ from PyQt5.QtQml import qmlRegisterUncreatableType
|
|||
|
||||
import platform
|
||||
import sys
|
||||
import os
|
||||
import os.path
|
||||
import numpy
|
||||
import copy
|
||||
|
|
|
@ -19,8 +19,6 @@ from . import PlatformPhysicsOperation
|
|||
from . import ConvexHullJob
|
||||
from . import ZOffsetDecorator
|
||||
|
||||
import time
|
||||
import threading
|
||||
import copy
|
||||
|
||||
class PlatformPhysics:
|
||||
|
@ -132,7 +130,7 @@ class PlatformPhysics:
|
|||
else:
|
||||
overlap = node.callDecoration("getConvexHull").intersectsPolygon(other_node.callDecoration("getConvexHull"))
|
||||
except:
|
||||
overlap = None #It can sometimes occur that the caclulated convex hull has no size, in which case there is no overlap.
|
||||
overlap = None #It can sometimes occur that the calculated convex hull has no size, in which case there is no overlap.
|
||||
|
||||
if overlap is None:
|
||||
continue
|
||||
|
|
|
@ -10,18 +10,18 @@ from UM.Qt.Duration import Duration
|
|||
|
||||
import math
|
||||
|
||||
## A class for processing and calculating minimum, currrent and maximum print time.
|
||||
## A class for processing and calculating minimum, current and maximum print time.
|
||||
#
|
||||
# This class contains all the logic relating to calculation and slicing for the
|
||||
# time/quality slider concept. It is a rather tricky combination of event handling
|
||||
# and state management. The logic behind this is as follows:
|
||||
#
|
||||
# - A scene change or settting change event happens.
|
||||
# - A scene change or setting change event happens.
|
||||
# We track what the source was of the change, either a scene change, a setting change, an active machine change or something else.
|
||||
# - This triggers a new slice with the current settings - this is the "current settings pass".
|
||||
# - When the slice is done, we update the current print time and material amount.
|
||||
# - If the source of the slice was not a Setting change, we start the second slice pass, the "low quality settings pass". Otherwise we stop here.
|
||||
# - When that is done, we update the minimum print time and start the final slcice pass, the "high quality settings pass".
|
||||
# - When that is done, we update the minimum print time and start the final slice pass, the "high quality settings pass".
|
||||
# - When the high quality pass is done, we update the maximum print time.
|
||||
#
|
||||
class PrintInformation(QObject):
|
||||
|
|
|
@ -4,11 +4,10 @@
|
|||
# Cura is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
def exceptHook(type, value, traceback):
|
||||
def exceptHook(hook_type, value, traceback):
|
||||
import cura.CrashHandler
|
||||
cura.CrashHandler.show(type, value, traceback)
|
||||
cura.CrashHandler.show(hook_type, value, traceback)
|
||||
|
||||
sys.excepthook = exceptHook
|
||||
|
||||
|
@ -16,7 +15,7 @@ sys.excepthook = exceptHook
|
|||
# is a race condition between Arcus and PyQt. Importing Arcus
|
||||
# first seems to prevent Sip from going into a state where it
|
||||
# tries to create PyQt objects on a non-main thread.
|
||||
import Arcus
|
||||
import Arcus #@UnusedImport
|
||||
import cura.CuraApplication
|
||||
|
||||
if sys.platform == "win32" and hasattr(sys, "frozen"):
|
||||
|
|
|
@ -12,10 +12,7 @@ from UM.Math.Quaternion import Quaternion
|
|||
|
||||
from UM.Job import Job
|
||||
|
||||
import os
|
||||
import struct
|
||||
import math
|
||||
from os import listdir
|
||||
import zipfile
|
||||
|
||||
import xml.etree.ElementTree as ET
|
||||
|
@ -32,8 +29,6 @@ class ThreeMFReader(MeshReader):
|
|||
}
|
||||
|
||||
def read(self, file_name):
|
||||
result = None
|
||||
|
||||
result = SceneNode()
|
||||
# The base object of 3mf is a zipped archive.
|
||||
archive = zipfile.ZipFile(file_name, "r")
|
||||
|
@ -46,16 +41,16 @@ class ThreeMFReader(MeshReader):
|
|||
Logger.log("w", "No objects found in 3MF file %s, either the file is corrupt or you are using an outdated format", file_name)
|
||||
return None
|
||||
|
||||
for object in objects:
|
||||
for entry in objects:
|
||||
mesh = MeshData()
|
||||
node = SceneNode()
|
||||
vertex_list = []
|
||||
#for vertex in object.mesh.vertices.vertex:
|
||||
for vertex in object.findall(".//3mf:vertex", self._namespaces):
|
||||
#for vertex in entry.mesh.vertices.vertex:
|
||||
for vertex in entry.findall(".//3mf:vertex", self._namespaces):
|
||||
vertex_list.append([vertex.get("x"), vertex.get("y"), vertex.get("z")])
|
||||
Job.yieldThread()
|
||||
|
||||
triangles = object.findall(".//3mf:triangle", self._namespaces)
|
||||
triangles = entry.findall(".//3mf:triangle", self._namespaces)
|
||||
|
||||
mesh.reserveFaceCount(len(triangles))
|
||||
|
||||
|
@ -72,7 +67,7 @@ class ThreeMFReader(MeshReader):
|
|||
node.setMeshData(mesh)
|
||||
node.setSelectable(True)
|
||||
|
||||
transformation = root.findall("./3mf:build/3mf:item[@objectid='{0}']".format(object.get("id")), self._namespaces)
|
||||
transformation = root.findall("./3mf:build/3mf:item[@objectid='{0}']".format(entry.get("id")), self._namespaces)
|
||||
if transformation:
|
||||
transformation = transformation[0]
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
# Cura is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
from UM.View.View import View
|
||||
from UM.View.Renderer import Renderer
|
||||
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
||||
from UM.Resources import Resources
|
||||
from UM.Event import Event, KeyEvent
|
||||
|
@ -11,7 +10,6 @@ from UM.Scene.Selection import Selection
|
|||
from UM.Math.Color import Color
|
||||
from UM.Mesh.MeshData import MeshData
|
||||
from UM.Job import Job
|
||||
from UM.Message import Message
|
||||
|
||||
from UM.View.RenderBatch import RenderBatch
|
||||
from UM.View.GL.OpenGL import OpenGL
|
||||
|
@ -23,7 +21,6 @@ from PyQt5.QtWidgets import QApplication
|
|||
|
||||
from . import LayerViewProxy
|
||||
|
||||
import time
|
||||
from UM.i18n import i18nCatalog
|
||||
catalog = i18nCatalog("cura")
|
||||
|
||||
|
@ -139,7 +136,7 @@ class LayerView(View):
|
|||
|
||||
def calculateMaxLayers(self):
|
||||
scene = self.getController().getScene()
|
||||
renderer = self.getRenderer()
|
||||
renderer = self.getRenderer() # TODO: Unused variable
|
||||
self._activity = True
|
||||
|
||||
self._old_max_layers = self._max_layers
|
||||
|
|
|
@ -51,10 +51,10 @@ class LegacyProfileReader(ProfileReader):
|
|||
# \return A set of local variables, one for each setting in the legacy
|
||||
# profile.
|
||||
def prepareLocals(self, config_parser, config_section, defaults):
|
||||
locals = defaults.copy() #Don't edit the original!
|
||||
copied_locals = defaults.copy() #Don't edit the original!
|
||||
for option in config_parser.options(config_section):
|
||||
locals[option] = config_parser.get(config_section, option)
|
||||
return locals
|
||||
copied_locals[option] = config_parser.get(config_section, option)
|
||||
return copied_locals
|
||||
|
||||
## Reads a legacy Cura profile from a file and returns it.
|
||||
#
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
from UM.Tool import Tool
|
||||
from UM.Scene.Selection import Selection
|
||||
from UM.Application import Application
|
||||
from UM.Qt.ListModel import ListModel
|
||||
from UM.Preferences import Preferences
|
||||
|
||||
from . import PerObjectSettingsModel
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
from . import RemovableDrivePlugin
|
||||
|
||||
from UM.Logger import Logger
|
||||
|
||||
import glob
|
||||
import os
|
||||
import subprocess
|
||||
|
@ -33,6 +35,7 @@ class LinuxRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin):
|
|||
def performEjectDevice(self, device):
|
||||
p = subprocess.Popen(["umount", device.getId()], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
output = p.communicate()
|
||||
Logger.log("d", "umount returned: %s.", repr(output))
|
||||
|
||||
return_code = p.wait()
|
||||
if return_code != 0:
|
||||
|
|
|
@ -4,10 +4,9 @@
|
|||
|
||||
from . import RemovableDrivePlugin
|
||||
|
||||
import threading
|
||||
from UM.Logger import Logger
|
||||
|
||||
import subprocess
|
||||
import time
|
||||
import os
|
||||
|
||||
import plistlib
|
||||
|
@ -44,8 +43,9 @@ class OSXRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin):
|
|||
return drives
|
||||
|
||||
def performEjectDevice(self, device):
|
||||
p = subprocess.Popen(["diskutil", "eject", path], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
p = subprocess.Popen(["diskutil", "eject", device.getId()], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
output = p.communicate()
|
||||
Logger.log("d", "umount returned: %s.", repr(output))
|
||||
|
||||
return_code = p.wait()
|
||||
if return_code != 0:
|
||||
|
|
|
@ -66,7 +66,7 @@ class SliceInfo(Extension):
|
|||
break
|
||||
|
||||
|
||||
profile_values = settings.getChangedSettings()
|
||||
profile_values = settings.getChangedSettings() # TODO: Unused variable
|
||||
|
||||
# Get total material used (in mm^3)
|
||||
print_information = Application.getInstance().getPrintInformation()
|
||||
|
|
|
@ -8,7 +8,6 @@ import time
|
|||
import queue
|
||||
import re
|
||||
import functools
|
||||
import os
|
||||
import os.path
|
||||
|
||||
from UM.Application import Application
|
||||
|
|
|
@ -19,7 +19,6 @@ import threading
|
|||
import platform
|
||||
import glob
|
||||
import time
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
from UM.Extension import Extension
|
||||
|
@ -60,7 +59,7 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension):
|
|||
@pyqtProperty(float, notify = progressChanged)
|
||||
def progress(self):
|
||||
progress = 0
|
||||
for name, connection in self._printer_connections.items():
|
||||
for printer_name, connection in self._printer_connections.items():
|
||||
progress += connection.progress
|
||||
|
||||
return progress / len(self._printer_connections)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue