From b9514527dd4ce0a5da7834af338eb804a1399b57 Mon Sep 17 00:00:00 2001 From: Victor Larchenko Date: Tue, 11 Oct 2016 17:20:55 +0600 Subject: [PATCH] T466: Added test line --- plugins/GCODEReader/GCODEReader.py | 75 +++++++++++++++++++++++++----- plugins/LayerView/LayerPass.py | 8 +++- 2 files changed, 71 insertions(+), 12 deletions(-) diff --git a/plugins/GCODEReader/GCODEReader.py b/plugins/GCODEReader/GCODEReader.py index ce6fd9075e..683355c9a3 100644 --- a/plugins/GCODEReader/GCODEReader.py +++ b/plugins/GCODEReader/GCODEReader.py @@ -7,6 +7,15 @@ from UM.Mesh.MeshBuilder import MeshBuilder import os from UM.Scene.SceneNode import SceneNode from UM.Math.Vector import Vector +from UM.Math.AxisAlignedBox import AxisAlignedBox +from UM.Application import Application + +from cura import LayerDataBuilder +from cura import LayerDataDecorator +from cura import LayerPolygon + +import numpy + from UM.Job import Job @@ -22,19 +31,63 @@ class GCODEReader(MeshReader): if extension.lower() in self._supported_extensions: scene_node = SceneNode() - mesh_builder = MeshBuilder() - mesh_builder.setFileName(file_name) + # 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()) - mesh_builder.addCube( - width=5, - height=5, - depth=5, - center=Vector(0, 2.5, 0) - ) + def getBoundingBox(): + return AxisAlignedBox(minimum=Vector(0, 0, 0), maximum=Vector(10, 10, 10)) - scene_node.setMeshData(mesh_builder.build()) + scene_node.getBoundingBox = getBoundingBox + scene_node.gcode = True - scene_node.setEnabled(False) - scene_node.setSelectable(False) + layer_data = LayerDataBuilder.LayerDataBuilder() + layer_count = 1 + for id in range(layer_count): + layer_data.addLayer(id) + this_layer = layer_data.getLayer(id) + layer_data.setLayerHeight(id, 1) + layer_data.setLayerThickness(id, 1) + + extruder = 1 + line_types = numpy.empty((1, 1), numpy.int32) + line_types[0, 0] = 6 + line_widths = numpy.empty((1, 1), numpy.int32) + line_widths[0, 0] = 1 + points = numpy.empty((2, 3), numpy.float32) + points[0, 0] = 0 + points[0, 1] = 0 + points[0, 2] = 0 + points[1, 0] = 10 + points[1, 1] = 10 + points[1, 2] = 10 + + this_poly = LayerPolygon.LayerPolygon(layer_data, extruder, line_types, points, line_widths) + this_poly.buildCache() + + this_layer.polygons.append(this_poly) + + layer_mesh = layer_data.build() + decorator = LayerDataDecorator.LayerDataDecorator() + decorator.setLayerData(layer_mesh) + scene_node.addDecorator(decorator) + + scene_node_parent = Application.getInstance().getBuildVolume() + scene_node.setParent(scene_node_parent) + + view = Application.getInstance().getController().getActiveView() + if view.getPluginId() == "LayerView": + view.resetLayerData() + + #scene_node.setEnabled(False) + #scene_node.setSelectable(False) return scene_node diff --git a/plugins/LayerView/LayerPass.py b/plugins/LayerView/LayerPass.py index 8ff2eb16ec..cf3e5cd89a 100644 --- a/plugins/LayerView/LayerPass.py +++ b/plugins/LayerView/LayerPass.py @@ -45,10 +45,16 @@ class LayerPass(RenderPass): tool_handle_batch = RenderBatch(self._tool_handle_shader, type = RenderBatch.RenderType.Overlay) for node in DepthFirstIterator(self._scene.getRoot()): + flag = False + try: + flag = node.gcode + except AttributeError: + pass + if isinstance(node, ToolHandle): 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 flag) and node.isVisible(): layer_data = node.callDecoration("getLayerData") if not layer_data: continue