CURA-4772 Create a CuraSceneNode instead of a SceneNode when reading a

GCode. Avoid creating an empty CuraSceneNode if the node is already an
instance of it.
This commit is contained in:
Diego Prado Gesto 2018-01-09 09:16:21 +01:00
parent 42b232756e
commit 4c8c4c78da
3 changed files with 8 additions and 6 deletions

View file

@ -1432,7 +1432,9 @@ class CuraApplication(QtApplication):
target_build_plate = self.getBuildPlateModel().activeBuildPlate if arrange_objects_on_load else -1 target_build_plate = self.getBuildPlateModel().activeBuildPlate if arrange_objects_on_load else -1
for original_node in nodes: for original_node in nodes:
node = CuraSceneNode() # We want our own CuraSceneNode
# Create a CuraSceneNode just if the original node is not that type
node = original_node if isinstance(original_node, CuraSceneNode) else CuraSceneNode()
node.setMeshData(original_node.getMeshData()) node.setMeshData(original_node.getMeshData())
node.setSelectable(True) node.setSelectable(True)

View file

@ -8,14 +8,14 @@ from UM.Logger import Logger
from UM.Math.AxisAlignedBox import AxisAlignedBox from UM.Math.AxisAlignedBox import AxisAlignedBox
from UM.Math.Vector import Vector from UM.Math.Vector import Vector
from UM.Message import Message from UM.Message import Message
from UM.Scene.SceneNode import SceneNode from cura.Scene.CuraSceneNode import CuraSceneNode
from UM.i18n import i18nCatalog from UM.i18n import i18nCatalog
from UM.Preferences import Preferences from UM.Preferences import Preferences
catalog = i18nCatalog("cura") catalog = i18nCatalog("cura")
from cura import LayerDataBuilder from cura import LayerDataBuilder
from cura import LayerDataDecorator from cura.LayerDataDecorator import LayerDataDecorator
from cura.LayerPolygon import LayerPolygon from cura.LayerPolygon import LayerPolygon
from cura.Scene.GCodeListDecorator import GCodeListDecorator from cura.Scene.GCodeListDecorator import GCodeListDecorator
from cura.Settings.ExtruderManager import ExtruderManager from cura.Settings.ExtruderManager import ExtruderManager
@ -292,7 +292,7 @@ class FlavorParser:
# We obtain the filament diameter from the selected printer to calculate line widths # We obtain the filament diameter from the selected printer to calculate line widths
self._filament_diameter = Application.getInstance().getGlobalContainerStack().getProperty("material_diameter", "value") self._filament_diameter = Application.getInstance().getGlobalContainerStack().getProperty("material_diameter", "value")
scene_node = SceneNode() scene_node = CuraSceneNode()
# Override getBoundingBox function of the sceneNode, as this node should return a bounding box, but there is no # Override getBoundingBox function of the sceneNode, as this node should return a bounding box, but there is no
# real data to calculate it from. # real data to calculate it from.
scene_node.getBoundingBox = self._getNullBoundingBox scene_node.getBoundingBox = self._getNullBoundingBox
@ -422,7 +422,7 @@ class FlavorParser:
material_color_map[0, :] = [0.0, 0.7, 0.9, 1.0] material_color_map[0, :] = [0.0, 0.7, 0.9, 1.0]
material_color_map[1, :] = [0.7, 0.9, 0.0, 1.0] material_color_map[1, :] = [0.7, 0.9, 0.0, 1.0]
layer_mesh = self._layer_data_builder.build(material_color_map) layer_mesh = self._layer_data_builder.build(material_color_map)
decorator = LayerDataDecorator.LayerDataDecorator() decorator = LayerDataDecorator()
decorator.setLayerData(layer_mesh) decorator.setLayerData(layer_mesh)
scene_node.addDecorator(decorator) scene_node.addDecorator(decorator)

View file

@ -106,7 +106,7 @@ class SimulationPass(RenderPass):
nozzle_node = node nozzle_node = node
nozzle_node.setVisible(False) nozzle_node.setVisible(False)
elif issubclass(type(node), SceneNode) and (node.getMeshData() or node.callDecoration("isBlockSlicing")) and node.isVisible() and node.callDecoration("getBuildPlateNumber") == active_build_plate: elif issubclass(type(node), SceneNode) and (node.getMeshData() or node.callDecoration("isBlockSlicing")) and node.isVisible():
layer_data = node.callDecoration("getLayerData") layer_data = node.callDecoration("getLayerData")
if not layer_data: if not layer_data:
continue continue