From 726b935b783d8e21e3bc5195456b6b2adc3f525c Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 4 Nov 2016 17:03:52 +0100 Subject: [PATCH 1/5] 3mf reader now gives warning if it couldn't load cElementTree --- plugins/3MFReader/ThreeMFReader.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/3MFReader/ThreeMFReader.py b/plugins/3MFReader/ThreeMFReader.py index 633eb8bb02..a32e8483f8 100644 --- a/plugins/3MFReader/ThreeMFReader.py +++ b/plugins/3MFReader/ThreeMFReader.py @@ -16,6 +16,7 @@ import zipfile try: import xml.etree.cElementTree as ET + Logger.log("w", "Unable to load cElementTree, switching to slower version") except ImportError: import xml.etree.ElementTree as ET From 35a4fe60d0834696bb13ac53c2c39e69a9ddea80 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 4 Nov 2016 17:12:20 +0100 Subject: [PATCH 2/5] Put the XML warning in the right spot --- plugins/3MFReader/ThreeMFReader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/3MFReader/ThreeMFReader.py b/plugins/3MFReader/ThreeMFReader.py index a32e8483f8..a06c557276 100644 --- a/plugins/3MFReader/ThreeMFReader.py +++ b/plugins/3MFReader/ThreeMFReader.py @@ -16,8 +16,8 @@ import zipfile try: import xml.etree.cElementTree as ET - Logger.log("w", "Unable to load cElementTree, switching to slower version") except ImportError: + Logger.log("w", "Unable to load cElementTree, switching to slower version") import xml.etree.ElementTree as ET ## Base implementation for reading 3MF files. Has no support for textures. Only loads meshes! From f8a5ee8c9bd0635345939da99f0ecf15c592940a Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Sun, 6 Nov 2016 15:38:52 +0100 Subject: [PATCH 3/5] USBPrinting: Removing superfluous empty lines Contributes to CURA-1809 --- plugins/USBPrinting/USBPrinterOutputDevice.py | 1 - plugins/USBPrinting/avr_isp/intelHex.py | 1 - 2 files changed, 2 deletions(-) diff --git a/plugins/USBPrinting/USBPrinterOutputDevice.py b/plugins/USBPrinting/USBPrinterOutputDevice.py index 6147bfb53f..13dfe967b3 100644 --- a/plugins/USBPrinting/USBPrinterOutputDevice.py +++ b/plugins/USBPrinting/USBPrinterOutputDevice.py @@ -19,7 +19,6 @@ from PyQt5.QtCore import QUrl, pyqtSlot, pyqtSignal, pyqtProperty from UM.i18n import i18nCatalog catalog = i18nCatalog("cura") - class USBPrinterOutputDevice(PrinterOutputDevice): def __init__(self, serial_port): diff --git a/plugins/USBPrinting/avr_isp/intelHex.py b/plugins/USBPrinting/avr_isp/intelHex.py index 6e27595587..a51c798d8e 100644 --- a/plugins/USBPrinting/avr_isp/intelHex.py +++ b/plugins/USBPrinting/avr_isp/intelHex.py @@ -7,7 +7,6 @@ This is a python 3 conversion of the code created by David Braam for the Cura pr import io from UM.Logger import Logger - def readHex(filename): """ Read an verify an intel hex file. Return the data as an list of bytes. From 8503492b4d7021befae3254d6bc117b94fdc74b3 Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Sun, 6 Nov 2016 15:40:28 +0100 Subject: [PATCH 4/5] USBPrinting: stk500v2 cleanups * Removing unneeded import of "os" * Removing unused "e" from SerialException * Adding #@UndefinedVariable tags for PyDev * Making message in Logger.log more detailed for portList(). Might be confusing in the logs to see just a list of ports without knowing where it is from. Contributes to CURA-1809 --- plugins/USBPrinting/avr_isp/stk500v2.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/plugins/USBPrinting/avr_isp/stk500v2.py b/plugins/USBPrinting/avr_isp/stk500v2.py index 3bbecb06c2..ccbaa3de53 100644 --- a/plugins/USBPrinting/avr_isp/stk500v2.py +++ b/plugins/USBPrinting/avr_isp/stk500v2.py @@ -3,7 +3,6 @@ STK500v2 protocol implementation for programming AVR chips. The STK500v2 protocol is used by the ArduinoMega2560 and a few other Arduino platforms to load firmware. This is a python 3 conversion of the code created by David Braam for the Cura project. """ -import os import struct import sys import time @@ -28,7 +27,7 @@ class Stk500v2(ispBase.IspBase): self.close() try: self.serial = Serial(str(port), speed, timeout=1, writeTimeout=10000) - except SerialException as e: + except SerialException: raise ispBase.IspError("Failed to open serial port") except: raise ispBase.IspError("Unexpected error while connecting to serial port:" + port + ":" + str(sys.exc_info()[0])) @@ -92,7 +91,7 @@ class Stk500v2(ispBase.IspBase): self.sendMessage([0x06, 0x00, 0x00, 0x00, 0x00]) load_count = (len(flash_data) + page_size - 1) / page_size for i in range(0, int(load_count)): - recv = self.sendMessage([0x13, page_size >> 8, page_size & 0xFF, 0xc1, 0x0a, 0x40, 0x4c, 0x20, 0x00, 0x00] + flash_data[(i * page_size):(i * page_size + page_size)]) + self.sendMessage([0x13, page_size >> 8, page_size & 0xFF, 0xc1, 0x0a, 0x40, 0x4c, 0x20, 0x00, 0x00] + flash_data[(i * page_size):(i * page_size + page_size)]) if self.progress_callback is not None: if self._has_checksum: self.progress_callback(i + 1, load_count) @@ -183,11 +182,11 @@ class Stk500v2(ispBase.IspBase): def portList(): ret = [] import _winreg - key=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"HARDWARE\\DEVICEMAP\\SERIALCOMM") + key=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"HARDWARE\\DEVICEMAP\\SERIALCOMM") #@UndefinedVariable i=0 while True: try: - values = _winreg.EnumValue(key, i) + values = _winreg.EnumValue(key, i) #@UndefinedVariable except: return ret if "USBSER" in values[0]: @@ -206,7 +205,7 @@ def main(): """ Entry point to call the stk500v2 programmer from the commandline. """ import threading if sys.argv[1] == "AUTO": - Logger.log("d", portList()) + Logger.log("d", "portList(): ", repr(portList())) for port in portList(): threading.Thread(target=runProgrammer, args=(port,sys.argv[2])).start() time.sleep(5) From e7df64da8be45b3231aab0101749b437013f307c Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 7 Nov 2016 11:19:03 +0100 Subject: [PATCH 5/5] Fixed merging for already grouped objects --- cura/CuraApplication.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index c2a08cadfc..d5f90f6846 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -866,7 +866,7 @@ class CuraApplication(QtApplication): return # Compute the center of the objects when their origins are aligned. - object_centers = [node.getMeshData().getCenterPosition().scale(node.getScale()) for node in group_node.getChildren() if node.getMeshData()] + object_centers = [node.getBoundingBox().center for node in group_node.getChildren()] if object_centers and len(object_centers) > 0: middle_x = sum([v.x for v in object_centers]) / len(object_centers) middle_y = sum([v.y for v in object_centers]) / len(object_centers) @@ -874,11 +874,10 @@ class CuraApplication(QtApplication): offset = Vector(middle_x, middle_y, middle_z) else: offset = Vector(0, 0, 0) - # Move each node to the same position. for center, node in zip(object_centers, group_node.getChildren()): # Align the object and also apply the offset to center it inside the group. - node.setPosition(center - offset) + node.translate(-1 * (center - offset), SceneNode.TransformSpace.World) # Use the previously found center of the group bounding box as the new location of the group group_node.setPosition(group_node.getBoundingBox().center)