mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-07-04 09:35:10 +08:00
Merge branch 'master' of github.com:Ultimaker/Cura
This commit is contained in:
commit
5c3310a01e
@ -866,7 +866,7 @@ class CuraApplication(QtApplication):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Compute the center of the objects when their origins are aligned.
|
# 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:
|
if object_centers and len(object_centers) > 0:
|
||||||
middle_x = sum([v.x for v in object_centers]) / len(object_centers)
|
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)
|
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)
|
offset = Vector(middle_x, middle_y, middle_z)
|
||||||
else:
|
else:
|
||||||
offset = Vector(0, 0, 0)
|
offset = Vector(0, 0, 0)
|
||||||
|
|
||||||
# Move each node to the same position.
|
# Move each node to the same position.
|
||||||
for center, node in zip(object_centers, group_node.getChildren()):
|
for center, node in zip(object_centers, group_node.getChildren()):
|
||||||
# Align the object and also apply the offset to center it inside the group.
|
# 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
|
# Use the previously found center of the group bounding box as the new location of the group
|
||||||
group_node.setPosition(group_node.getBoundingBox().center)
|
group_node.setPosition(group_node.getBoundingBox().center)
|
||||||
|
@ -17,6 +17,7 @@ import zipfile
|
|||||||
try:
|
try:
|
||||||
import xml.etree.cElementTree as ET
|
import xml.etree.cElementTree as ET
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
Logger.log("w", "Unable to load cElementTree, switching to slower version")
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
## Base implementation for reading 3MF files. Has no support for textures. Only loads meshes!
|
## Base implementation for reading 3MF files. Has no support for textures. Only loads meshes!
|
||||||
|
@ -19,7 +19,6 @@ from PyQt5.QtCore import QUrl, pyqtSlot, pyqtSignal, pyqtProperty
|
|||||||
from UM.i18n import i18nCatalog
|
from UM.i18n import i18nCatalog
|
||||||
catalog = i18nCatalog("cura")
|
catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
|
|
||||||
class USBPrinterOutputDevice(PrinterOutputDevice):
|
class USBPrinterOutputDevice(PrinterOutputDevice):
|
||||||
|
|
||||||
def __init__(self, serial_port):
|
def __init__(self, serial_port):
|
||||||
|
@ -7,7 +7,6 @@ This is a python 3 conversion of the code created by David Braam for the Cura pr
|
|||||||
import io
|
import io
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
|
|
||||||
|
|
||||||
def readHex(filename):
|
def readHex(filename):
|
||||||
"""
|
"""
|
||||||
Read an verify an intel hex file. Return the data as an list of bytes.
|
Read an verify an intel hex file. Return the data as an list of bytes.
|
||||||
|
@ -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.
|
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.
|
This is a python 3 conversion of the code created by David Braam for the Cura project.
|
||||||
"""
|
"""
|
||||||
import os
|
|
||||||
import struct
|
import struct
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
@ -28,7 +27,7 @@ class Stk500v2(ispBase.IspBase):
|
|||||||
self.close()
|
self.close()
|
||||||
try:
|
try:
|
||||||
self.serial = Serial(str(port), speed, timeout=1, writeTimeout=10000)
|
self.serial = Serial(str(port), speed, timeout=1, writeTimeout=10000)
|
||||||
except SerialException as e:
|
except SerialException:
|
||||||
raise ispBase.IspError("Failed to open serial port")
|
raise ispBase.IspError("Failed to open serial port")
|
||||||
except:
|
except:
|
||||||
raise ispBase.IspError("Unexpected error while connecting to serial port:" + port + ":" + str(sys.exc_info()[0]))
|
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])
|
self.sendMessage([0x06, 0x00, 0x00, 0x00, 0x00])
|
||||||
load_count = (len(flash_data) + page_size - 1) / page_size
|
load_count = (len(flash_data) + page_size - 1) / page_size
|
||||||
for i in range(0, int(load_count)):
|
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.progress_callback is not None:
|
||||||
if self._has_checksum:
|
if self._has_checksum:
|
||||||
self.progress_callback(i + 1, load_count)
|
self.progress_callback(i + 1, load_count)
|
||||||
@ -183,11 +182,11 @@ class Stk500v2(ispBase.IspBase):
|
|||||||
def portList():
|
def portList():
|
||||||
ret = []
|
ret = []
|
||||||
import _winreg
|
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
|
i=0
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
values = _winreg.EnumValue(key, i)
|
values = _winreg.EnumValue(key, i) #@UndefinedVariable
|
||||||
except:
|
except:
|
||||||
return ret
|
return ret
|
||||||
if "USBSER" in values[0]:
|
if "USBSER" in values[0]:
|
||||||
@ -206,7 +205,7 @@ def main():
|
|||||||
""" Entry point to call the stk500v2 programmer from the commandline. """
|
""" Entry point to call the stk500v2 programmer from the commandline. """
|
||||||
import threading
|
import threading
|
||||||
if sys.argv[1] == "AUTO":
|
if sys.argv[1] == "AUTO":
|
||||||
Logger.log("d", portList())
|
Logger.log("d", "portList(): ", repr(portList()))
|
||||||
for port in portList():
|
for port in portList():
|
||||||
threading.Thread(target=runProgrammer, args=(port,sys.argv[2])).start()
|
threading.Thread(target=runProgrammer, args=(port,sys.argv[2])).start()
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user