mirror of
https://github.com/Ultimaker/Cura.git
synced 2026-01-06 14:47:45 -07:00
Fix sometimes wrongly displayed view
CURA-12660 This required a refactoring of the management of the active view. The previous behavior was that anyone could set the active view, depending on certain conditions. But now we also have a view that is set by a tool, so sometimes the actually set view would be incorrect. Now each Stage requests an active view, and each tool CAN also request an active view. Then the Controller decides which view should actually be active depending on the active stage and tool.
This commit is contained in:
parent
cf24ed91e9
commit
e69a436942
7 changed files with 34 additions and 60 deletions
|
|
@ -172,13 +172,20 @@ class SimulationView(CuraView):
|
|||
self._updateSliceWarningVisibility()
|
||||
self.activityChanged.emit()
|
||||
|
||||
def getSimulationPass(self) -> SimulationPass:
|
||||
def getSimulationPass(self) -> Optional[SimulationPass]:
|
||||
if not self._layer_pass:
|
||||
renderer = self.getRenderer()
|
||||
if renderer is None:
|
||||
return None
|
||||
|
||||
# Currently the RenderPass constructor requires a size > 0
|
||||
# This should be fixed in RenderPass's constructor.
|
||||
self._layer_pass = SimulationPass(1, 1)
|
||||
self._compatibility_mode = self._evaluateCompatibilityMode()
|
||||
self._layer_pass.setSimulationView(self)
|
||||
self._layer_pass.setEnabled(False)
|
||||
renderer.addRenderPass(self._layer_pass)
|
||||
|
||||
return self._layer_pass
|
||||
|
||||
def getCurrentLayer(self) -> int:
|
||||
|
|
@ -734,11 +741,14 @@ class SimulationView(CuraView):
|
|||
|
||||
# Make sure the SimulationPass is created
|
||||
layer_pass = self.getSimulationPass()
|
||||
if layer_pass is None:
|
||||
return False
|
||||
|
||||
renderer = self.getRenderer()
|
||||
if renderer is None:
|
||||
return False
|
||||
|
||||
renderer.addRenderPass(layer_pass)
|
||||
layer_pass.setEnabled(True)
|
||||
|
||||
# Make sure the NozzleNode is add to the root
|
||||
nozzle = self.getNozzleNode()
|
||||
|
|
@ -778,7 +788,7 @@ class SimulationView(CuraView):
|
|||
return False
|
||||
|
||||
if self._layer_pass is not None:
|
||||
renderer.removeRenderPass(self._layer_pass)
|
||||
self._layer_pass.setEnabled(False)
|
||||
if self._composite_pass:
|
||||
self._composite_pass.setLayerBindings(cast(List[str], self._old_layer_bindings))
|
||||
self._composite_pass.setCompositeShader(cast(ShaderProgram, self._old_composite_shader))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue