mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
Added extruder count detection to layer view. CURA-3273
This commit is contained in:
parent
5f6ed488d1
commit
5a2aa8846b
4 changed files with 54 additions and 10 deletions
|
@ -50,6 +50,7 @@ class ExtruderManager(QObject):
|
|||
except KeyError: # Extruder index could be -1 if the global tab is selected, or the entry doesn't exist if the machine definition is wrong.
|
||||
return None
|
||||
|
||||
## Return extruder count according to extruder trains.
|
||||
@pyqtProperty(int, notify = extrudersChanged)
|
||||
def extruderCount(self):
|
||||
if not UM.Application.getInstance().getGlobalContainerStack():
|
||||
|
|
|
@ -18,6 +18,7 @@ from UM.Message import Message
|
|||
from UM.Application import Application
|
||||
|
||||
from cura.ConvexHullNode import ConvexHullNode
|
||||
from cura.Settings.ExtruderManager import ExtruderManager
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
|
@ -59,13 +60,7 @@ class LayerView(View):
|
|||
self._proxy = LayerViewProxy.LayerViewProxy()
|
||||
self._controller.getScene().getRoot().childrenChanged.connect(self._onSceneChanged)
|
||||
|
||||
self._layer_view_type = 0 # 0 is material color, 1 is color by linetype, 2 is speed
|
||||
self._extruder_opacity = [1.0, 1.0, 1.0, 1.0]
|
||||
self._show_travel_moves = 0
|
||||
self._show_support = 1
|
||||
self._show_adhesion = 1
|
||||
self._show_skin = 1
|
||||
self._show_infill = 1
|
||||
self._resetSettings()
|
||||
self._legend_items = None
|
||||
|
||||
Preferences.getInstance().addPreference("view/top_layer_count", 5)
|
||||
|
@ -80,6 +75,16 @@ class LayerView(View):
|
|||
|
||||
self._wireprint_warning_message = Message(catalog.i18nc("@info:status", "Cura does not accurately display layers when Wire Printing is enabled"))
|
||||
|
||||
def _resetSettings(self):
|
||||
self._layer_view_type = 0 # 0 is material color, 1 is color by linetype, 2 is speed
|
||||
self._extruder_count = 0
|
||||
self._extruder_opacity = [1.0, 1.0, 1.0, 1.0]
|
||||
self._show_travel_moves = 0
|
||||
self._show_support = 1
|
||||
self._show_adhesion = 1
|
||||
self._show_skin = 1
|
||||
self._show_infill = 1
|
||||
|
||||
def getActivity(self):
|
||||
return self._activity
|
||||
|
||||
|
@ -211,6 +216,9 @@ class LayerView(View):
|
|||
def getCompatibilityMode(self):
|
||||
return self._compatibility_mode
|
||||
|
||||
def getExtruderCount(self):
|
||||
return self._extruder_count
|
||||
|
||||
def calculateMaxLayers(self):
|
||||
scene = self.getController().getScene()
|
||||
self._activity = True
|
||||
|
@ -242,6 +250,7 @@ class LayerView(View):
|
|||
|
||||
maxLayersChanged = Signal()
|
||||
currentLayerNumChanged = Signal()
|
||||
globalStackChanged = Signal()
|
||||
|
||||
## Hackish way to ensure the proxy is already created, which ensures that the layerview.qml is already created
|
||||
# as this caused some issues.
|
||||
|
@ -302,7 +311,9 @@ class LayerView(View):
|
|||
self._global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||
if self._global_container_stack:
|
||||
self._global_container_stack.propertyChanged.connect(self._onPropertyChanged)
|
||||
self._extruder_count = self._global_container_stack.getProperty("machine_extruder_count", "value")
|
||||
self._onPropertyChanged("wireframe_enabled", "value")
|
||||
self.globalStackChanged.emit()
|
||||
else:
|
||||
self._wireprint_warning_message.hide()
|
||||
|
||||
|
|
|
@ -203,7 +203,7 @@ Item
|
|||
UM.LayerView.setExtruderOpacity(0, checked ? 1.0 : 0.0);
|
||||
}
|
||||
text: "Extruder 1"
|
||||
visible: !UM.LayerView.compatibilityMode
|
||||
visible: !UM.LayerView.compatibilityMode && (UM.LayerView.getExtruderCount >= 1)
|
||||
}
|
||||
CheckBox {
|
||||
checked: true
|
||||
|
@ -211,7 +211,27 @@ Item
|
|||
UM.LayerView.setExtruderOpacity(1, checked ? 1.0 : 0.0);
|
||||
}
|
||||
text: "Extruder 2"
|
||||
visible: !UM.LayerView.compatibilityMode
|
||||
visible: !UM.LayerView.compatibilityMode && (UM.LayerView.getExtruderCount >= 2)
|
||||
}
|
||||
CheckBox {
|
||||
checked: true
|
||||
onClicked: {
|
||||
UM.LayerView.setExtruderOpacity(2, checked ? 1.0 : 0.0);
|
||||
}
|
||||
text: "Extruder 3"
|
||||
visible: !UM.LayerView.compatibilityMode && (UM.LayerView.getExtruderCount >= 3)
|
||||
}
|
||||
CheckBox {
|
||||
checked: true
|
||||
onClicked: {
|
||||
UM.LayerView.setExtruderOpacity(3, checked ? 1.0 : 0.0);
|
||||
}
|
||||
text: "Extruder 4"
|
||||
visible: !UM.LayerView.compatibilityMode && (UM.LayerView.getExtruderCount >= 4)
|
||||
}
|
||||
Label {
|
||||
text: "Other extruders always visible"
|
||||
visible: !UM.LayerView.compatibilityMode && (UM.LayerView.getExtruderCount >= 5)
|
||||
}
|
||||
CheckBox {
|
||||
onClicked: {
|
||||
|
|
|
@ -16,6 +16,7 @@ class LayerViewProxy(QObject):
|
|||
currentLayerChanged = pyqtSignal()
|
||||
maxLayersChanged = pyqtSignal()
|
||||
activityChanged = pyqtSignal()
|
||||
globalStackChanged = pyqtSignal()
|
||||
|
||||
@pyqtProperty(bool, notify = activityChanged)
|
||||
def getLayerActivity(self):
|
||||
|
@ -121,6 +122,13 @@ class LayerViewProxy(QObject):
|
|||
if type(active_view) == LayerView.LayerView.LayerView:
|
||||
active_view.setShowInfill(show)
|
||||
|
||||
@pyqtProperty(int, notify = globalStackChanged)
|
||||
def getExtruderCount(self):
|
||||
active_view = self._controller.getActiveView()
|
||||
if type(active_view) == LayerView.LayerView.LayerView:
|
||||
return active_view.getExtruderCount()
|
||||
return 0
|
||||
|
||||
def _layerActivityChanged(self):
|
||||
self.activityChanged.emit()
|
||||
|
||||
|
@ -134,9 +142,13 @@ class LayerViewProxy(QObject):
|
|||
def _onBusyChanged(self):
|
||||
self.busyChanged.emit()
|
||||
|
||||
def _onGlobalStackChanged(self):
|
||||
self.globalStackChanged.emit()
|
||||
|
||||
def _onActiveViewChanged(self):
|
||||
active_view = self._controller.getActiveView()
|
||||
if type(active_view) == LayerView.LayerView.LayerView:
|
||||
active_view.currentLayerNumChanged.connect(self._onLayerChanged)
|
||||
active_view.maxLayersChanged.connect(self._onMaxLayersChanged)
|
||||
active_view.busyChanged.connect(self._onBusyChanged)
|
||||
active_view.globalStackChanged.connect(self._onGlobalStackChanged)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue