mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Update colour scheme limits if visibility changed the limits
If the user makes certain structures visible or invisible, and this then causes the limits of the colour scheme to change, this now triggers the layer view to be re-rendered and updates the legend in the simulation view menu component.
This commit is contained in:
parent
424f037dca
commit
9f902f7a7a
3 changed files with 39 additions and 19 deletions
|
@ -466,6 +466,14 @@ class SimulationView(CuraView):
|
||||||
"""
|
"""
|
||||||
Calculates the limits of the colour schemes, depending on the layer view data that is visible to the user.
|
Calculates the limits of the colour schemes, depending on the layer view data that is visible to the user.
|
||||||
"""
|
"""
|
||||||
|
# Before we start, save the old values so that we can tell if any of the spectrums need to change.
|
||||||
|
old_min_feedrate = self._min_feedrate
|
||||||
|
old_max_feedrate = self._max_feedrate
|
||||||
|
old_min_linewidth = self._min_line_width
|
||||||
|
old_max_linewidth = self._max_line_width
|
||||||
|
old_min_thickness = self._min_thickness
|
||||||
|
old_max_thickness = self._max_thickness
|
||||||
|
|
||||||
# The colour scheme is only influenced by the visible lines, so filter the lines by if they should be visible.
|
# The colour scheme is only influenced by the visible lines, so filter the lines by if they should be visible.
|
||||||
visible_line_types = []
|
visible_line_types = []
|
||||||
if self.getShowSkin(): # Actually "shell".
|
if self.getShowSkin(): # Actually "shell".
|
||||||
|
@ -509,6 +517,11 @@ class SimulationView(CuraView):
|
||||||
# Sometimes, when importing a GCode the line thicknesses are zero and so the minimum (avoiding the zero) can't be calculated.
|
# Sometimes, when importing a GCode the line thicknesses are zero and so the minimum (avoiding the zero) can't be calculated.
|
||||||
Logger.log("i", "Min thickness can't be calculated because all the values are zero")
|
Logger.log("i", "Min thickness can't be calculated because all the values are zero")
|
||||||
|
|
||||||
|
if old_min_feedrate != self._min_feedrate or old_max_feedrate != self._max_feedrate \
|
||||||
|
or old_min_linewidth != self._min_line_width or old_max_linewidth != self._max_line_width \
|
||||||
|
or old_min_thickness != self._min_thickness or old_max_thickness != self._max_thickness:
|
||||||
|
self.colorSchemeLimitsChanged.emit()
|
||||||
|
|
||||||
def calculateMaxPathsOnLayer(self, layer_num: int) -> None:
|
def calculateMaxPathsOnLayer(self, layer_num: int) -> None:
|
||||||
# Update the currentPath
|
# Update the currentPath
|
||||||
scene = self.getController().getScene()
|
scene = self.getController().getScene()
|
||||||
|
@ -536,6 +549,7 @@ class SimulationView(CuraView):
|
||||||
busyChanged = Signal()
|
busyChanged = Signal()
|
||||||
activityChanged = Signal()
|
activityChanged = Signal()
|
||||||
visibleStructuresChanged = Signal()
|
visibleStructuresChanged = Signal()
|
||||||
|
colorSchemeLimitsChanged = Signal()
|
||||||
|
|
||||||
def getProxy(self, engine, script_engine):
|
def getProxy(self, engine, script_engine):
|
||||||
"""Hackish way to ensure the proxy is already created
|
"""Hackish way to ensure the proxy is already created
|
||||||
|
|
|
@ -389,17 +389,17 @@ Cura.ExpandableComponent
|
||||||
// Feedrate selected
|
// Feedrate selected
|
||||||
if (UM.Preferences.getValue("layerview/layer_view_type") == 2)
|
if (UM.Preferences.getValue("layerview/layer_view_type") == 2)
|
||||||
{
|
{
|
||||||
return parseFloat(UM.SimulationView.getMinFeedrate()).toFixed(2)
|
return parseFloat(UM.SimulationView.minFeedrate).toFixed(2)
|
||||||
}
|
}
|
||||||
// Layer thickness selected
|
// Layer thickness selected
|
||||||
if (UM.Preferences.getValue("layerview/layer_view_type") == 3)
|
if (UM.Preferences.getValue("layerview/layer_view_type") == 3)
|
||||||
{
|
{
|
||||||
return parseFloat(UM.SimulationView.getMinThickness()).toFixed(2)
|
return parseFloat(UM.SimulationView.minThickness).toFixed(2)
|
||||||
}
|
}
|
||||||
//Line width selected
|
//Line width selected
|
||||||
if(UM.Preferences.getValue("layerview/layer_view_type") == 4)
|
if(UM.Preferences.getValue("layerview/layer_view_type") == 4)
|
||||||
{
|
{
|
||||||
return parseFloat(UM.SimulationView.getMinLineWidth()).toFixed(2);
|
return parseFloat(UM.SimulationView.minLineWidth).toFixed(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return catalog.i18nc("@label","min")
|
return catalog.i18nc("@label","min")
|
||||||
|
@ -448,17 +448,17 @@ Cura.ExpandableComponent
|
||||||
// Feedrate selected
|
// Feedrate selected
|
||||||
if (UM.Preferences.getValue("layerview/layer_view_type") == 2)
|
if (UM.Preferences.getValue("layerview/layer_view_type") == 2)
|
||||||
{
|
{
|
||||||
return parseFloat(UM.SimulationView.getMaxFeedrate()).toFixed(2)
|
return parseFloat(UM.SimulationView.maxFeedrate).toFixed(2)
|
||||||
}
|
}
|
||||||
// Layer thickness selected
|
// Layer thickness selected
|
||||||
if (UM.Preferences.getValue("layerview/layer_view_type") == 3)
|
if (UM.Preferences.getValue("layerview/layer_view_type") == 3)
|
||||||
{
|
{
|
||||||
return parseFloat(UM.SimulationView.getMaxThickness()).toFixed(2)
|
return parseFloat(UM.SimulationView.maxThickness).toFixed(2)
|
||||||
}
|
}
|
||||||
//Line width selected
|
//Line width selected
|
||||||
if(UM.Preferences.getValue("layerview/layer_view_type") == 4)
|
if(UM.Preferences.getValue("layerview/layer_view_type") == 4)
|
||||||
{
|
{
|
||||||
return parseFloat(UM.SimulationView.getMaxLineWidth()).toFixed(2);
|
return parseFloat(UM.SimulationView.maxLineWidth).toFixed(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return catalog.i18nc("@label","max")
|
return catalog.i18nc("@label","max")
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Copyright (c) 2018 Ultimaker B.V.
|
# Copyright (c) 2021 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ class SimulationViewProxy(QObject):
|
||||||
globalStackChanged = pyqtSignal()
|
globalStackChanged = pyqtSignal()
|
||||||
preferencesChanged = pyqtSignal()
|
preferencesChanged = pyqtSignal()
|
||||||
busyChanged = pyqtSignal()
|
busyChanged = pyqtSignal()
|
||||||
|
colorSchemeLimitsChanged = pyqtSignal()
|
||||||
|
|
||||||
@pyqtProperty(bool, notify=activityChanged)
|
@pyqtProperty(bool, notify=activityChanged)
|
||||||
def layerActivity(self):
|
def layerActivity(self):
|
||||||
|
@ -101,28 +102,28 @@ class SimulationViewProxy(QObject):
|
||||||
def getSimulationRunning(self):
|
def getSimulationRunning(self):
|
||||||
return self._simulation_view.isSimulationRunning()
|
return self._simulation_view.isSimulationRunning()
|
||||||
|
|
||||||
@pyqtSlot(result=float)
|
@pyqtProperty(float, notify = colorSchemeLimitsChanged)
|
||||||
def getMinFeedrate(self):
|
def minFeedrate(self):
|
||||||
return self._simulation_view.getMinFeedrate()
|
return self._simulation_view.getMinFeedrate()
|
||||||
|
|
||||||
@pyqtSlot(result=float)
|
@pyqtProperty(float, notify = colorSchemeLimitsChanged)
|
||||||
def getMaxFeedrate(self):
|
def maxFeedrate(self):
|
||||||
return self._simulation_view.getMaxFeedrate()
|
return self._simulation_view.getMaxFeedrate()
|
||||||
|
|
||||||
@pyqtSlot(result=float)
|
@pyqtProperty(float, notify = colorSchemeLimitsChanged)
|
||||||
def getMinThickness(self):
|
def minThickness(self):
|
||||||
return self._simulation_view.getMinThickness()
|
return self._simulation_view.getMinThickness()
|
||||||
|
|
||||||
@pyqtSlot(result=float)
|
@pyqtProperty(float, notify = colorSchemeLimitsChanged)
|
||||||
def getMaxThickness(self):
|
def maxThickness(self):
|
||||||
return self._simulation_view.getMaxThickness()
|
return self._simulation_view.getMaxThickness()
|
||||||
|
|
||||||
@pyqtSlot(result=float)
|
@pyqtProperty(float, notify = colorSchemeLimitsChanged)
|
||||||
def getMaxLineWidth(self):
|
def maxLineWidth(self):
|
||||||
return self._simulation_view.getMaxLineWidth()
|
return self._simulation_view.getMaxLineWidth()
|
||||||
|
|
||||||
@pyqtSlot(result=float)
|
@pyqtProperty(float, notify = colorSchemeLimitsChanged)
|
||||||
def getMinLineWidth(self):
|
def minLineWidth(self):
|
||||||
return self._simulation_view.getMinLineWidth()
|
return self._simulation_view.getMinLineWidth()
|
||||||
|
|
||||||
# Opacity 0..1
|
# Opacity 0..1
|
||||||
|
@ -153,6 +154,9 @@ class SimulationViewProxy(QObject):
|
||||||
self.currentLayerChanged.emit()
|
self.currentLayerChanged.emit()
|
||||||
self._layerActivityChanged()
|
self._layerActivityChanged()
|
||||||
|
|
||||||
|
def _onColorSchemeLimitsChanged(self):
|
||||||
|
self.colorSchemeLimitsChanged.emit()
|
||||||
|
|
||||||
def _onPathChanged(self):
|
def _onPathChanged(self):
|
||||||
self.currentPathChanged.emit()
|
self.currentPathChanged.emit()
|
||||||
self._layerActivityChanged()
|
self._layerActivityChanged()
|
||||||
|
@ -182,6 +186,7 @@ class SimulationViewProxy(QObject):
|
||||||
active_view = self._controller.getActiveView()
|
active_view = self._controller.getActiveView()
|
||||||
if active_view == self._simulation_view:
|
if active_view == self._simulation_view:
|
||||||
self._simulation_view.currentLayerNumChanged.connect(self._onLayerChanged)
|
self._simulation_view.currentLayerNumChanged.connect(self._onLayerChanged)
|
||||||
|
self._simulation_view.colorSchemeLimitsChanged.connect(self._onColorSchemeLimitsChanged)
|
||||||
self._simulation_view.currentPathNumChanged.connect(self._onPathChanged)
|
self._simulation_view.currentPathNumChanged.connect(self._onPathChanged)
|
||||||
self._simulation_view.maxLayersChanged.connect(self._onMaxLayersChanged)
|
self._simulation_view.maxLayersChanged.connect(self._onMaxLayersChanged)
|
||||||
self._simulation_view.maxPathsChanged.connect(self._onMaxPathsChanged)
|
self._simulation_view.maxPathsChanged.connect(self._onMaxPathsChanged)
|
||||||
|
@ -194,6 +199,7 @@ class SimulationViewProxy(QObject):
|
||||||
# Disconnect all of em again.
|
# Disconnect all of em again.
|
||||||
self.is_simulationView_selected = False
|
self.is_simulationView_selected = False
|
||||||
self._simulation_view.currentLayerNumChanged.disconnect(self._onLayerChanged)
|
self._simulation_view.currentLayerNumChanged.disconnect(self._onLayerChanged)
|
||||||
|
self._simulation_view.colorSchemeLimitsChanged.connect(self._onColorSchemeLimitsChanged)
|
||||||
self._simulation_view.currentPathNumChanged.disconnect(self._onPathChanged)
|
self._simulation_view.currentPathNumChanged.disconnect(self._onPathChanged)
|
||||||
self._simulation_view.maxLayersChanged.disconnect(self._onMaxLayersChanged)
|
self._simulation_view.maxLayersChanged.disconnect(self._onMaxLayersChanged)
|
||||||
self._simulation_view.maxPathsChanged.disconnect(self._onMaxPathsChanged)
|
self._simulation_view.maxPathsChanged.disconnect(self._onMaxPathsChanged)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue