mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 00:55:51 +08:00
Fix mypy issues caused by scenenode iterator being correctly typed
This commit is contained in:
parent
9ceb9ce18b
commit
827ccd5a13
@ -1262,7 +1262,7 @@ class CuraApplication(QtApplication):
|
||||
@pyqtSlot()
|
||||
def arrangeObjectsToAllBuildPlates(self) -> None:
|
||||
nodes_to_arrange = []
|
||||
for node in DepthFirstIterator(self.getController().getScene().getRoot()): # type: ignore
|
||||
for node in DepthFirstIterator(self.getController().getScene().getRoot()):
|
||||
if not isinstance(node, SceneNode):
|
||||
continue
|
||||
|
||||
@ -1339,9 +1339,9 @@ class CuraApplication(QtApplication):
|
||||
return
|
||||
|
||||
for node in nodes:
|
||||
file_name = node.getMeshData().getFileName()
|
||||
if file_name:
|
||||
job = ReadMeshJob(file_name)
|
||||
mesh_data = node.getMeshData()
|
||||
if mesh_data and mesh_data.getFileName():
|
||||
job = ReadMeshJob(mesh_data.getFileName())
|
||||
job._node = node # type: ignore
|
||||
job.finished.connect(self._reloadMeshFinished)
|
||||
if has_merged_nodes:
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
from typing import Optional, TYPE_CHECKING
|
||||
|
||||
from numpy import cast
|
||||
|
||||
from UM.Application import Application
|
||||
from UM.Resources import Resources
|
||||
|
||||
@ -12,6 +14,7 @@ from UM.View.RenderBatch import RenderBatch
|
||||
|
||||
|
||||
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
||||
from cura.Scene.CuraSceneNode import CuraSceneNode
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from UM.View.GL.ShaderProgram import ShaderProgram
|
||||
@ -44,9 +47,9 @@ class PreviewPass(RenderPass):
|
||||
|
||||
self._renderer = Application.getInstance().getRenderer()
|
||||
|
||||
self._shader = None #type: Optional[ShaderProgram]
|
||||
self._non_printing_shader = None #type: Optional[ShaderProgram]
|
||||
self._support_mesh_shader = None #type: Optional[ShaderProgram]
|
||||
self._shader = None # type: Optional[ShaderProgram]
|
||||
self._non_printing_shader = None # type: Optional[ShaderProgram]
|
||||
self._support_mesh_shader = None # type: Optional[ShaderProgram]
|
||||
self._scene = Application.getInstance().getController().getScene()
|
||||
|
||||
# Set the camera to be used by this render pass
|
||||
@ -83,8 +86,8 @@ class PreviewPass(RenderPass):
|
||||
batch_support_mesh = RenderBatch(self._support_mesh_shader)
|
||||
|
||||
# Fill up the batch with objects that can be sliced.
|
||||
for node in DepthFirstIterator(self._scene.getRoot()): #type: ignore #Ignore type error because iter() should get called automatically by Python syntax.
|
||||
if hasattr(node, "_outside_buildarea") and not node._outside_buildarea:
|
||||
for node in DepthFirstIterator(self._scene.getRoot()):
|
||||
if hasattr(node, "_outside_buildarea") and not getattr(node, "_outside_buildarea"):
|
||||
if node.callDecoration("isSliceable") and node.getMeshData() and node.isVisible():
|
||||
per_mesh_stack = node.callDecoration("getStack")
|
||||
if node.callDecoration("isNonThumbnailVisibleMesh"):
|
||||
@ -94,7 +97,7 @@ class PreviewPass(RenderPass):
|
||||
# Support mesh
|
||||
uniforms = {}
|
||||
shade_factor = 0.6
|
||||
diffuse_color = node.getDiffuseColor()
|
||||
diffuse_color = cast(CuraSceneNode, node).getDiffuseColor()
|
||||
diffuse_color2 = [
|
||||
diffuse_color[0] * shade_factor,
|
||||
diffuse_color[1] * shade_factor,
|
||||
@ -106,7 +109,7 @@ class PreviewPass(RenderPass):
|
||||
else:
|
||||
# Normal scene node
|
||||
uniforms = {}
|
||||
uniforms["diffuse_color"] = prettier_color(node.getDiffuseColor())
|
||||
uniforms["diffuse_color"] = prettier_color(cast(CuraSceneNode, node).getDiffuseColor())
|
||||
batch.addItem(node.getWorldTransformation(), node.getMeshData(), uniforms = uniforms)
|
||||
|
||||
self.bind()
|
||||
|
Loading…
x
Reference in New Issue
Block a user