T466: Removed cube, Changed label, Added clearing of scene

This commit is contained in:
Victor Larchenko 2016-10-13 16:55:24 +06:00 committed by Youness Alaoui
parent 0a75c3d19b
commit 333e501268
5 changed files with 34 additions and 14 deletions

View file

@ -581,7 +581,7 @@ class CuraApplication(QtApplication):
count = 0 count = 0
scene_bounding_box = None scene_bounding_box = None
for node in DepthFirstIterator(self.getController().getScene().getRoot()): for node in DepthFirstIterator(self.getController().getScene().getRoot()):
if type(node) is not SceneNode or not node.getMeshData(): if type(node) is not SceneNode or (not node.getMeshData() and not hasattr(node, "gcode")):
continue continue
count += 1 count += 1
@ -712,7 +712,7 @@ class CuraApplication(QtApplication):
for node in DepthFirstIterator(self.getController().getScene().getRoot()): for node in DepthFirstIterator(self.getController().getScene().getRoot()):
if type(node) is not SceneNode: if type(node) is not SceneNode:
continue continue
if not node.getMeshData() and not node.callDecoration("isGroup"): if (not node.getMeshData() and not hasattr(node, "gcode")) and not node.callDecoration("isGroup"):
continue # Node that doesnt have a mesh and is not a group. continue # Node that doesnt have a mesh and is not a group.
if node.getParent() and node.getParent().callDecoration("isGroup"): if node.getParent() and node.getParent().callDecoration("isGroup"):
continue # Grouped nodes don't need resetting as their parent (the group) is resetted) continue # Grouped nodes don't need resetting as their parent (the group) is resetted)

View file

@ -60,7 +60,7 @@ 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 # break
if self._abort_requested: if self._abort_requested:
if self._progress: if self._progress:
self._progress.hide() self._progress.hide()

View file

@ -4,11 +4,15 @@
from UM.Mesh.MeshReader import MeshReader from UM.Mesh.MeshReader import MeshReader
from UM.Mesh.MeshBuilder import MeshBuilder 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.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
from cura import LayerDataDecorator from cura import LayerDataDecorator
@ -59,6 +63,14 @@ class GCODEReader(MeshReader):
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:
scene = Application.getInstance().getController().getScene()
if getattr(scene, "gcode_list"):
setattr(scene, "gcode_list", None)
for node in DepthFirstIterator(scene.getRoot()):
if node.callDecoration("getLayerData"):
node.getParent().removeChild(node)
Application.getInstance().deleteAll()
scene_node = SceneNode() scene_node = SceneNode()
# mesh_builder = MeshBuilder() # mesh_builder = MeshBuilder()
@ -73,11 +85,14 @@ class GCODEReader(MeshReader):
# #
# scene_node.setMeshData(mesh_builder.build()) # scene_node.setMeshData(mesh_builder.build())
# scene_node.getBoundingBox = getBoundingBox def getBoundingBox():
return AxisAlignedBox(minimum=Vector(0, 0, 0), maximum=Vector(10, 10, 10))
scene_node.getBoundingBox = getBoundingBox
scene_node.gcode = True scene_node.gcode = True
backend = Application.getInstance().getBackend() # backend = Application.getInstance().getBackend()
backend._pauseSlicing = True # backend._pauseSlicing = True
backend.backendStateChange.emit(0) # backend.backendStateChange.emit(0)
file = open(file_name, "r") file = open(file_name, "r")
@ -183,12 +198,17 @@ class GCODEReader(MeshReader):
scene_node_parent = Application.getInstance().getBuildVolume() scene_node_parent = Application.getInstance().getBuildVolume()
scene_node.setParent(scene_node_parent) scene_node.setParent(scene_node_parent)
mesh_builder = MeshBuilder() # mesh_builder = MeshBuilder()
mesh_builder.setFileName(file_name) # mesh_builder.setFileName(file_name)
#
# mesh_builder.addCube(10, 10, 10, Vector(0, -5, 0))
mesh_builder.addCube(10, 10, 10, Vector(0, -5, 0)) # scene_node.setMeshData(mesh_builder.build())
# scene_node.setMeshData(MeshData(file_name=file_name))
scene_node.setMeshData(mesh_builder.build()) # Application.getInstance().getPrintInformation().JobName(file_name)
Preferences.getInstance().setValue("cura/jobname_prefix", False)
settings = Application.getInstance().getGlobalContainerStack() settings = Application.getInstance().getGlobalContainerStack()
machine_width = settings.getProperty("machine_width", "value") machine_width = settings.getProperty("machine_width", "value")
@ -200,7 +220,7 @@ class GCODEReader(MeshReader):
if view.getPluginId() == "LayerView": if view.getPluginId() == "LayerView":
view.resetLayerData() view.resetLayerData()
scene_node.setEnabled(False) # scene_node.setEnabled(False)
#scene_node.setSelectable(False) #scene_node.setSelectable(False)
return scene_node return scene_node

View file

@ -49,7 +49,7 @@ class LayerPass(RenderPass):
if isinstance(node, ToolHandle): if isinstance(node, ToolHandle):
tool_handle_batch.addItem(node.getWorldTransformation(), mesh = node.getSolidMesh()) tool_handle_batch.addItem(node.getWorldTransformation(), mesh = node.getSolidMesh())
elif isinstance(node, SceneNode) and (node.getMeshData()) and node.isVisible(): elif isinstance(node, SceneNode) and (node.getMeshData() or hasattr(node, "gcode")) and node.isVisible():
layer_data = node.callDecoration("getLayerData") layer_data = node.callDecoration("getLayerData")
if not layer_data: if not layer_data:
continue continue

View file

@ -119,7 +119,7 @@ class LayerView(View):
continue continue
if not node.render(renderer): if not node.render(renderer):
if node.getMeshData() and node.isVisible(): if (node.getMeshData()) and node.isVisible():
renderer.queueNode(node, transparent = True, shader = self._ghost_shader) renderer.queueNode(node, transparent = True, shader = self._ghost_shader)
def setLayer(self, value): def setLayer(self, value):