本文整理汇总了Python中UM.Scene.SceneNode.SceneNode类的典型用法代码示例。如果您正苦于以下问题:Python SceneNode类的具体用法?Python SceneNode怎么用?Python SceneNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SceneNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_getConvexHulLBoundaryPrintingMesh
def test_getConvexHulLBoundaryPrintingMesh(convex_hull_decorator):
node = SceneNode()
node.addDecorator(PrintingDecorator())
with patch("UM.Application.Application.getInstance", MagicMock(return_value=mocked_application)):
convex_hull_decorator.setNode(node)
# Should still be None, since print sequence is not one at a time
assert convex_hull_decorator.getConvexHullBoundary() is None
示例2: read
def read(self, file_name):
mesh_builder = MeshBuilder()
scene_node = SceneNode()
if use_numpystl:
self._loadWithNumpySTL(file_name, mesh_builder)
else:
f = open(file_name, "rb")
if not self._loadBinary(mesh_builder, f):
f.close()
f = open(file_name, "rt")
try:
self._loadAscii(mesh_builder, f)
except UnicodeDecodeError:
return None
f.close()
Job.yieldThread() # Yield somewhat to ensure the GUI has time to update a bit.
mesh_builder.calculateNormals(fast = True)
mesh = mesh_builder.build()
Logger.log("d", "Loaded a mesh with %s vertices", mesh_builder.getVertexCount())
scene_node.setMeshData(mesh)
return scene_node
示例3: read
def read(self, file_name):
self._dxf = DXFObjectReader.DXFObjectReader(open(file_name, "rt"))
self._mesh = MeshData()
for obj in self._dxf:
if obj.getName() == "SECTION":
if obj.get(2) == "ENTITIES":
self._handleEntities()
elif obj.get(2) == "TABLES":
self._handleTables()
else:
Logger.log("d", "DXF: Got unknown section: %s", obj.get(2))
for obj in self._dxf:
if obj.getName() == "ENDSEC":
break
else:
Logger.log("d", "DXF: %s", obj)
elif obj.getName() == "EOF":
pass
else:
Logger.log("e", "DXF: Unexpected object: %s", obj)
#self._mesh.calculateNormals()
node = SceneNode()
node.setMeshData(self._mesh)
return node
示例4: read
def read(self, file_name):
mesh_builder = MeshBuilder()
scene_node = SceneNode()
self.load_file(file_name, mesh_builder, _use_numpystl = use_numpystl)
mesh = mesh_builder.build()
if use_numpystl:
verts = mesh.getVertices()
# In some cases numpy stl reads incorrectly and the result is that the Z values are all 0
# Add new error cases if you find them.
if numpy.amin(verts[:, 1]) == numpy.amax(verts[:, 1]):
# Something may have gone wrong in numpy stl, start over without numpy stl
Logger.log("w", "All Z coordinates are the same using numpystl, trying again without numpy stl.")
mesh_builder = MeshBuilder()
self.load_file(file_name, mesh_builder, _use_numpystl = False)
mesh = mesh_builder.build()
verts = mesh.getVertices()
if numpy.amin(verts[:, 1]) == numpy.amax(verts[:, 1]):
Logger.log("e", "All Z coordinates are still the same without numpy stl... let's hope for the best")
if mesh_builder.getVertexCount() == 0:
Logger.log("d", "File did not contain valid data, unable to read.")
return None # We didn't load anything.
scene_node.setMeshData(mesh)
Logger.log("d", "Loaded a mesh with %s vertices", mesh_builder.getVertexCount())
return scene_node
示例5: test_multipleItemsRename
def test_multipleItemsRename(self, objects_model):
node1 = SceneNode()
node2 = SceneNode()
result = objects_model._renameNodes({"zomg": _NodeInfo(nodes_to_rename=[node1, node2])})
assert result == [node1, node2]
assert node1.getName() == "zomg(1)"
assert node2.getName() == "zomg(2)"
示例6: test_getConvexHullPrintingMesh
def test_getConvexHullPrintingMesh(convex_hull_decorator):
node = SceneNode()
node.addDecorator(PrintingDecorator())
with patch("UM.Application.Application.getInstance", MagicMock(return_value=mocked_application)):
convex_hull_decorator.setNode(node)
convex_hull_decorator._compute2DConvexHull = MagicMock(return_value = Polygon.approximatedCircle(10))
assert convex_hull_decorator.getConvexHull() == Polygon.approximatedCircle(10)
示例7: _reloadJobFinished
def _reloadJobFinished(self, replaced_node: SceneNode, job: ReadMeshJob) -> None:
for node in job.getResult():
mesh_data = node.getMeshData()
if mesh_data:
replaced_node.setMeshData(mesh_data)
else:
Logger.log("w", "Could not find a mesh in reloaded node.")
示例8: _onSceneChanged
def _onSceneChanged(self, scene_node: SceneNode) -> None:
# Ignore any changes that are not related to sliceable objects
if not isinstance(scene_node, SceneNode)\
or not scene_node.callDecoration("isSliceable")\
or not scene_node.callDecoration("getBuildPlateNumber") == self._active_build_plate:
return
self.setToZeroPrintInformation(self._active_build_plate)
示例9: _updateNodeListeners
def _updateNodeListeners(self, node: SceneNode):
per_mesh_stack = node.callDecoration("getStack")
if per_mesh_stack:
per_mesh_stack.propertyChanged.connect(self._onSettingPropertyChanged)
active_extruder_changed = node.callDecoration("getActiveExtruderChangedSignal")
if active_extruder_changed is not None:
active_extruder_changed.connect(self._updateDisallowedAreasAndRebuild)
self._updateDisallowedAreasAndRebuild()
示例10: test_addScale
def test_addScale():
node = SceneNode()
op = ScaleOperation(node, Vector(1, 2, 3), set_scale = True)
op.redo()
op2 = ScaleOperation(node, Vector(1, 2, 3), add_scale = True)
op2.redo()
assert node.getScale() == Vector(2, 4, 6)
示例11: test_relativeScale
def test_relativeScale():
node = SceneNode()
op = ScaleOperation(node, Vector(2, 2, 2), set_scale=True)
op.redo()
op2 = ScaleOperation(node, Vector(1, 2, 3), relative_scale=True)
op2.redo()
assert node.getScale() == Vector(3, 4, 5)
示例12: test_setSimpleScale
def test_setSimpleScale():
node = SceneNode()
op = ScaleOperation(node, Vector(1, 2, 3), set_scale = True)
op.redo()
assert node.getScale() == Vector(1, 2, 3)
op.undo()
assert node.getScale() == Vector(1, 1, 1)
示例13: test_getSelectionCenter
def test_getSelectionCenter(self):
node_1 = SceneNode()
node_1.getBoundingBox = MagicMock(return_value = AxisAlignedBox(Vector(0, 0, 0), Vector(10, 20, 30)))
Selection.add(node_1)
assert Selection.getSelectionCenter() == Vector(5, 10, 15)
node_2 = SceneNode()
node_2.getBoundingBox = MagicMock(return_value=AxisAlignedBox(Vector(0, 0, 0), Vector(20, 30, 40)))
Selection.add(node_2)
assert Selection.getSelectionCenter() == Vector(10, 15, 20)
示例14: test_getConvexHulLBoundaryPrintingMeshOneAtATime
def test_getConvexHulLBoundaryPrintingMeshOneAtATime(convex_hull_decorator):
node = SceneNode()
node.addDecorator(PrintingDecorator())
with patch("UM.Application.Application.getInstance", MagicMock(return_value=mocked_application)):
convex_hull_decorator.setNode(node)
convex_hull_decorator._global_stack = MagicMock()
convex_hull_decorator._global_stack.getProperty = MagicMock(return_value = "one_at_a_time")
# In this test we don't care for the result of the function, just that the convex hull computation is called.
convex_hull_decorator._compute2DConvexHull = MagicMock()
convex_hull_decorator.getConvexHullBoundary()
convex_hull_decorator._compute2DConvexHull.assert_called_once_with()
示例15: test_SimpleRedoUndo
def test_SimpleRedoUndo():
node = SceneNode()
parent_node = SceneNode()
operation = AddSceneNodeOperation(node, parent_node)
operation.redo()
assert node.getParent() == parent_node
operation.undo()
assert node.getParent() is None