mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-06-30 04:05:25 +08:00
T466: Cleaned code
This commit is contained in:
parent
b24d5ef12b
commit
5d0c598622
@ -19,9 +19,6 @@ from UM.SaveFile import SaveFile
|
|||||||
from UM.Scene.Selection import Selection
|
from UM.Scene.Selection import Selection
|
||||||
from UM.Scene.GroupDecorator import GroupDecorator
|
from UM.Scene.GroupDecorator import GroupDecorator
|
||||||
from UM.Settings.Validator import Validator
|
from UM.Settings.Validator import Validator
|
||||||
from types import MethodType
|
|
||||||
|
|
||||||
from UM.Qt.Bindings.MeshFileHandlerProxy import MeshFileHandlerProxy
|
|
||||||
|
|
||||||
from UM.Operations.AddSceneNodeOperation import AddSceneNodeOperation
|
from UM.Operations.AddSceneNodeOperation import AddSceneNodeOperation
|
||||||
from UM.Operations.RemoveSceneNodeOperation import RemoveSceneNodeOperation
|
from UM.Operations.RemoveSceneNodeOperation import RemoveSceneNodeOperation
|
||||||
|
@ -60,7 +60,6 @@ class ProcessSlicedLayersJob(Job):
|
|||||||
for node in DepthFirstIterator(self._scene.getRoot()):
|
for node in DepthFirstIterator(self._scene.getRoot()):
|
||||||
if node.callDecoration("getLayerData"):
|
if node.callDecoration("getLayerData"):
|
||||||
node.getParent().removeChild(node)
|
node.getParent().removeChild(node)
|
||||||
# break
|
|
||||||
if self._abort_requested:
|
if self._abort_requested:
|
||||||
if self._progress:
|
if self._progress:
|
||||||
self._progress.hide()
|
self._progress.hide()
|
||||||
|
@ -3,16 +3,12 @@
|
|||||||
# Uranium is released under the terms of the AGPLv3 or higher.
|
# Uranium is released under the terms of the AGPLv3 or higher.
|
||||||
|
|
||||||
from UM.Mesh.MeshReader import MeshReader
|
from UM.Mesh.MeshReader import MeshReader
|
||||||
from UM.Mesh.MeshBuilder import MeshBuilder
|
|
||||||
from UM.Mesh.MeshData import MeshData
|
|
||||||
import os
|
import os
|
||||||
from UM.Scene.SceneNode import SceneNode
|
from UM.Scene.SceneNode import SceneNode
|
||||||
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
||||||
from UM.Math.Vector import Vector
|
from UM.Math.Vector import Vector
|
||||||
from UM.Math.Color import Color
|
|
||||||
from UM.Math.AxisAlignedBox import AxisAlignedBox
|
from UM.Math.AxisAlignedBox import AxisAlignedBox
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
from UM.Preferences import Preferences
|
|
||||||
|
|
||||||
|
|
||||||
from cura import LayerDataBuilder
|
from cura import LayerDataBuilder
|
||||||
@ -20,11 +16,8 @@ from cura import LayerDataDecorator
|
|||||||
from cura import LayerPolygon
|
from cura import LayerPolygon
|
||||||
|
|
||||||
import numpy
|
import numpy
|
||||||
from types import MethodType
|
|
||||||
|
|
||||||
|
|
||||||
from UM.Job import Job
|
|
||||||
|
|
||||||
class GCODEReader(MeshReader):
|
class GCODEReader(MeshReader):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(GCODEReader, self).__init__()
|
super(GCODEReader, self).__init__()
|
||||||
@ -35,9 +28,6 @@ class GCODEReader(MeshReader):
|
|||||||
if n < 1:
|
if n < 1:
|
||||||
return None
|
return None
|
||||||
m = line.find(' ', n)
|
m = line.find(' ', n)
|
||||||
# m2 = line.find(';', n)
|
|
||||||
# if m < 0:
|
|
||||||
# m = m2
|
|
||||||
try:
|
try:
|
||||||
if m < 0:
|
if m < 0:
|
||||||
return int(line[n:])
|
return int(line[n:])
|
||||||
@ -50,9 +40,6 @@ class GCODEReader(MeshReader):
|
|||||||
if n < 1:
|
if n < 1:
|
||||||
return None
|
return None
|
||||||
m = line.find(' ', n)
|
m = line.find(' ', n)
|
||||||
# m2 = line.find(';', n)
|
|
||||||
# if m < 0:
|
|
||||||
# m = m2
|
|
||||||
try:
|
try:
|
||||||
if m < 0:
|
if m < 0:
|
||||||
return float(line[n:])
|
return float(line[n:])
|
||||||
@ -81,31 +68,15 @@ class GCODEReader(MeshReader):
|
|||||||
Application.getInstance().getPrintInformation().setPreSliced(True)
|
Application.getInstance().getPrintInformation().setPreSliced(True)
|
||||||
Application.getInstance().setHideSettings(True)
|
Application.getInstance().setHideSettings(True)
|
||||||
|
|
||||||
|
|
||||||
def read(self, file_name):
|
def read(self, file_name):
|
||||||
scene_node = None
|
scene_node = None
|
||||||
|
|
||||||
extension = os.path.splitext(file_name)[1]
|
extension = os.path.splitext(file_name)[1]
|
||||||
if extension.lower() in self._supported_extensions:
|
if extension.lower() in self._supported_extensions:
|
||||||
# for node in DepthFirstIterator(scene.getRoot()):
|
|
||||||
# if node.callDecoration("getLayerData"):
|
|
||||||
# node.getParent().removeChild(node)
|
|
||||||
Application.getInstance().deleteAll()
|
Application.getInstance().deleteAll()
|
||||||
|
|
||||||
scene_node = SceneNode()
|
scene_node = SceneNode()
|
||||||
|
|
||||||
# mesh_builder = MeshBuilder()
|
|
||||||
# mesh_builder.setFileName(file_name)
|
|
||||||
#
|
|
||||||
# mesh_builder.addCube(
|
|
||||||
# width=5,
|
|
||||||
# height=5,
|
|
||||||
# depth=5,
|
|
||||||
# center=Vector(0, 2.5, 0)
|
|
||||||
# )
|
|
||||||
#
|
|
||||||
# scene_node.setMeshData(mesh_builder.build())
|
|
||||||
|
|
||||||
def getBoundingBox():
|
def getBoundingBox():
|
||||||
return AxisAlignedBox(minimum=Vector(0, 0, 0), maximum=Vector(10, 10, 10))
|
return AxisAlignedBox(minimum=Vector(0, 0, 0), maximum=Vector(10, 10, 10))
|
||||||
|
|
||||||
@ -208,10 +179,7 @@ class GCODEReader(MeshReader):
|
|||||||
current_path.append([current_x, current_z, -current_y, 0])
|
current_path.append([current_x, current_z, -current_y, 0])
|
||||||
current_e = e
|
current_e = e
|
||||||
else:
|
else:
|
||||||
# if G == 0:
|
current_path.append([current_x, current_z, -current_y, 0])
|
||||||
# current_path.append([current_x, current_z, -current_y, 6])
|
|
||||||
# else:
|
|
||||||
current_path.append([current_x, current_z, -current_y, 0])
|
|
||||||
if z_changed:
|
if z_changed:
|
||||||
if len(current_path) > 1:
|
if len(current_path) > 1:
|
||||||
CreatePolygon()
|
CreatePolygon()
|
||||||
@ -247,9 +215,6 @@ class GCODEReader(MeshReader):
|
|||||||
|
|
||||||
Application.getInstance().getPrintInformation()._pre_sliced = True
|
Application.getInstance().getPrintInformation()._pre_sliced = True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
scene_node.parentChanged.connect(self.parent_changed)
|
scene_node.parentChanged.connect(self.parent_changed)
|
||||||
|
|
||||||
scene_node_parent = Application.getInstance().getBuildVolume()
|
scene_node_parent = Application.getInstance().getBuildVolume()
|
||||||
@ -261,23 +226,10 @@ class GCODEReader(MeshReader):
|
|||||||
|
|
||||||
scene_node.setPosition(Vector(-machine_width / 2, 0, machine_depth / 2))
|
scene_node.setPosition(Vector(-machine_width / 2, 0, machine_depth / 2))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# mesh_builder = MeshBuilder()
|
|
||||||
# mesh_builder.setFileName(file_name)
|
|
||||||
#
|
|
||||||
# mesh_builder.addCube(10, 10, 10, Vector(0, -5, 0))
|
|
||||||
|
|
||||||
# scene_node.setMeshData(mesh_builder.build())
|
|
||||||
# scene_node.setMeshData(MeshData(file_name=file_name))
|
|
||||||
|
|
||||||
view = Application.getInstance().getController().getActiveView()
|
view = Application.getInstance().getController().getActiveView()
|
||||||
if view.getPluginId() == "LayerView":
|
if view.getPluginId() == "LayerView":
|
||||||
view.resetLayerData()
|
view.resetLayerData()
|
||||||
view.setLayer(999999)
|
view.setLayer(999999)
|
||||||
view.calculateMaxLayers()
|
view.calculateMaxLayers()
|
||||||
|
|
||||||
# scene_node.setEnabled(False)
|
|
||||||
#scene_node.setSelectable(False)
|
|
||||||
|
|
||||||
return scene_node
|
return scene_node
|
||||||
|
Loading…
x
Reference in New Issue
Block a user