diff options
author | Ghostkeeper <rubend@tutanota.com> | 2022-04-12 17:05:43 +0300 |
---|---|---|
committer | Ghostkeeper <rubend@tutanota.com> | 2022-04-12 17:05:43 +0300 |
commit | cec55162ec006b4483e0feea47c5ee290afd18ed (patch) | |
tree | e43d8c83a6c11e9050a005ac8cb391e625a043bc | |
parent | 329d3781b997e69c688953d85a540c2afdaadb16 (diff) |
Fix StructureView and move SceneNode in there
For better separation of concerns, we'll just have the engine plug-in receive the message and pass it on to whoever is listening. The StructureView will be listening and is supposed to store the data.
-rwxr-xr-x | plugins/CuraEngineBackend/CuraEngineBackend.py | 8 | ||||
-rw-r--r-- | plugins/StructureView/StructureView.py | 17 | ||||
-rw-r--r-- | plugins/StructureView/plugin.json | 8 | ||||
-rw-r--r-- | resources/bundled_packages/cura.json | 17 |
4 files changed, 45 insertions, 5 deletions
diff --git a/plugins/CuraEngineBackend/CuraEngineBackend.py b/plugins/CuraEngineBackend/CuraEngineBackend.py index 019c663631..040d79f38e 100755 --- a/plugins/CuraEngineBackend/CuraEngineBackend.py +++ b/plugins/CuraEngineBackend/CuraEngineBackend.py @@ -724,15 +724,15 @@ class CuraEngineBackend(QObject, Backend): self._stored_optimized_layer_data[self._start_slice_job_build_plate] = [] self._stored_optimized_layer_data[self._start_slice_job_build_plate].append(message) + structurePolygonReceived = Signal() + def _onStructurePolygonMessage(self, message: Arcus.PythonMessage) -> None: """ Called when a structure polygon visualization is received from the - engine. + engine. This sends it on to a signal for others to listen to. :param message: The protobuf message containing a structure polygon. """ - print("----------- got a structure polygon message!") - #mesh_data = self._structure_vis_node.getMeshData() - #mesh_data.getVertices(). + self.structurePolygonReceived.emit(message) def _onProgressMessage(self, message: Arcus.PythonMessage) -> None: """Called when a progress message is received from the engine. diff --git a/plugins/StructureView/StructureView.py b/plugins/StructureView/StructureView.py index 9aeabbc5d5..c05c7220ae 100644 --- a/plugins/StructureView/StructureView.py +++ b/plugins/StructureView/StructureView.py @@ -1,7 +1,22 @@ # Copyright (c) 2022 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. +from typing import Optional + from cura.CuraView import CuraView +from cura.Scene.CuraSceneNode import CuraSceneNode +from UM.PluginRegistry import PluginRegistry class StructureView(CuraView): - pass # TODO
\ No newline at end of file + def __init__(self): + super().__init__(parent = None, use_empty_menu_placeholder = True) + self._root_node = None # type: Optional[CuraSceneNode] # All structure data will be under this node. Will be generated on first message received (since there is no scene yet at init). + + plugin_registry = PluginRegistry.getInstance() + self._enabled = "StructureView" not in plugin_registry.getDisabledPlugins() # Don't influence performance if this plug-in is disabled. + if self._enabled: + engine = plugin_registry.getPluginObject("CuraEngineBackend") + engine.structurePolygonReceived.connect(self._onStructurePolygonReceived) # type: ignore + + def _onStructurePolygonReceived(self, message): + print("Received structure polygon for layer", message.layer_index) diff --git a/plugins/StructureView/plugin.json b/plugins/StructureView/plugin.json new file mode 100644 index 0000000000..453c45c80a --- /dev/null +++ b/plugins/StructureView/plugin.json @@ -0,0 +1,8 @@ +{ + "name": "Structure View", + "author": "Ultimaker B.V.", + "version": "1.0.0", + "description": "Provides a preview of the printed structures while slicing.", + "api": 7, + "i18n-catalog": "cura" +} diff --git a/resources/bundled_packages/cura.json b/resources/bundled_packages/cura.json index 501445f9d8..b95f422ab8 100644 --- a/resources/bundled_packages/cura.json +++ b/resources/bundled_packages/cura.json @@ -492,6 +492,23 @@ } } }, + "StructureView": { + "package_info": { + "package_id": "StructureView", + "package_type": "plugin", + "display_name": "Structure View", + "description": "Provides a preview of the generated structures while slicing.", + "package_version": "1.0.0", + "sdk_version": "7.9.0", + "website": "https://ultimaker.com", + "author": { + "author_id": "UltimakerPackages", + "display_name": "Ultimaker B.V.", + "email": "plugins@ultimaker.com", + "website": "https://ultimaker.com" + } + } + }, "SupportEraser": { "package_info": { "package_id": "SupportEraser", |