diff options
author | Ghostkeeper <rubend@tutanota.com> | 2022-04-15 20:20:10 +0300 |
---|---|---|
committer | Ghostkeeper <rubend@tutanota.com> | 2022-04-15 20:20:10 +0300 |
commit | 1dbc054c974476a7dfb0c2aa2ea66f9d109efd26 (patch) | |
tree | b24a3a007ddc775afead259bfc4708994df3a3c9 | |
parent | a89631905b4bdeafc53d3b4a1014400339b73d49 (diff) |
Clear structure data when scene (meaningfully) changesimmediate_visualization
-rw-r--r-- | plugins/StructureView/StructureView.py | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/plugins/StructureView/StructureView.py b/plugins/StructureView/StructureView.py index 03fac39061..cdf3ad2323 100644 --- a/plugins/StructureView/StructureView.py +++ b/plugins/StructureView/StructureView.py @@ -57,11 +57,13 @@ class StructureView(CuraView): engine = plugin_registry.getPluginObject("CuraEngineBackend") engine.structurePolygonReceived.connect(self._onStructurePolygonReceived) # type: ignore - CuraApplication.getInstance().initializationFinished.connect(self._createSceneNode) + CuraApplication.getInstance().initializationFinished.connect(self._createSceneNode) def _createSceneNode(self): + scene = CuraApplication.getInstance().getController().getScene() if not self._scene_node: - self._scene_node = StructureNode(parent = CuraApplication.getInstance().getController().getScene().getRoot()) + self._scene_node = StructureNode(parent = scene.getRoot()) + scene.sceneChanged.connect(self._clear) def _onStructurePolygonReceived(self, message: "pyArcus.PythonMessage") -> None: """ @@ -113,3 +115,23 @@ class StructureView(CuraView): indices = self._indices[0:int(self._current_index / 3)], colors = self._colors[0:self._current_index] )) + + def _clear(self, source: "SceneNode") -> None: + """ + Removes the structure data from the scene when the scene changes. + :param source: The scene node that changed. + """ + scene = CuraApplication.getInstance().getController().getScene() + if not source.callDecoration("isSliceable") and source != scene.getRoot(): + return + + if source.callDecoration("getBuildPlateNumber") is None: # Not on the build plate. + return + if not source.callDecoration("isGroup"): + mesh_data = source.getMeshData() + if mesh_data is None or mesh_data.getVertices() is None: + return + + if self._current_index != 0: + self._current_index = 0 + self._updateScene() |