From e8cd5723c97d956f2629f13ef0df8fd3370e8685 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 27 Aug 2019 13:26:55 +0200 Subject: [PATCH] Speedup the layerview We were doing a lot of re-calculations that served no purpose (and even slowed down the rest of the application) --- plugins/SimulationView/SimulationView.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/SimulationView/SimulationView.py b/plugins/SimulationView/SimulationView.py index e7bb88e1ae..72bf1274ea 100644 --- a/plugins/SimulationView/SimulationView.py +++ b/plugins/SimulationView/SimulationView.py @@ -90,7 +90,6 @@ class SimulationView(CuraView): self._global_container_stack = None # type: Optional[ContainerStack] self._proxy = None - self._controller.getScene().getRoot().childrenChanged.connect(self._onSceneChanged) self._resetSettings() self._legend_items = None @@ -109,7 +108,6 @@ class SimulationView(CuraView): Application.getInstance().getPreferences().addPreference("layerview/show_skin", True) Application.getInstance().getPreferences().addPreference("layerview/show_infill", True) - Application.getInstance().getPreferences().preferenceChanged.connect(self._onPreferencesChanged) self._updateWithPreferences() self._solid_layers = int(Application.getInstance().getPreferences().getValue("view/top_layer_count")) @@ -184,6 +182,8 @@ class SimulationView(CuraView): return self._nozzle_node def _onSceneChanged(self, node: "SceneNode") -> None: + if node.getMeshData() is None: + return self.setActivity(False) self.calculateMaxLayers() self.calculateMaxPathsOnLayer(self._current_layer_num) @@ -464,6 +464,10 @@ class SimulationView(CuraView): return True if event.type == Event.ViewActivateEvent: + # Start listening to changes. + Application.getInstance().getPreferences().preferenceChanged.connect(self._onPreferencesChanged) + self._controller.getScene().getRoot().childrenChanged.connect(self._onSceneChanged) + # FIX: on Max OS X, somehow QOpenGLContext.currentContext() can become None during View switching. # This can happen when you do the following steps: # 1. Start Cura @@ -510,6 +514,8 @@ class SimulationView(CuraView): self._composite_pass.setCompositeShader(self._simulationview_composite_shader) elif event.type == Event.ViewDeactivateEvent: + self._controller.getScene().getRoot().childrenChanged.disconnect(self._onSceneChanged) + Application.getInstance().getPreferences().preferenceChanged.disconnect(self._onPreferencesChanged) self._wireprint_warning_message.hide() Application.getInstance().globalContainerStackChanged.disconnect(self._onGlobalStackChanged) if self._global_container_stack: