mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-09 07:56:22 -06:00
Merge branch 'feature_intent' of github.com:Ultimaker/Cura into feature_intent_container_tree
This commit is contained in:
commit
f7d61e1e24
15 changed files with 121 additions and 339 deletions
|
@ -1,6 +1,6 @@
|
|||
# Copyright (c) 2019 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
from .BaseModel import BaseModel
|
||||
from ..BaseModel import BaseModel
|
||||
|
||||
|
||||
class ClusterMaterial(BaseModel):
|
|
@ -8,13 +8,13 @@ from .ClusterPrinterMaterialStationSlot import ClusterPrinterMaterialStationSlot
|
|||
|
||||
## Class representing the data of a Material Station in the cluster.
|
||||
class ClusterPrinterMaterialStation(BaseModel):
|
||||
|
||||
|
||||
## Creates a new Material Station status.
|
||||
# \param status: The status of the material station.
|
||||
# \param: supported: Whether the material station is supported on this machine or not.
|
||||
# \param material_slots: The active slots configurations of this material station.
|
||||
def __init__(self, status: str, supported: bool = False,
|
||||
material_slots: Union[None, Dict[str, Any], ClusterPrinterMaterialStationSlot] = None,
|
||||
material_slots: List[Union[ClusterPrinterMaterialStationSlot, Dict[str, Any]]] = None,
|
||||
**kwargs) -> None:
|
||||
self.status = status
|
||||
self.supported = supported
|
||||
|
|
|
@ -13,6 +13,7 @@ from .ClusterBuildPlate import ClusterBuildPlate
|
|||
from .ClusterPrintCoreConfiguration import ClusterPrintCoreConfiguration
|
||||
from .ClusterPrinterMaterialStation import ClusterPrinterMaterialStation
|
||||
from .ClusterPrinterMaterialStationSlot import ClusterPrinterMaterialStationSlot
|
||||
from .ClusterPrinterConfigurationMaterial import ClusterPrinterConfigurationMaterial
|
||||
from ..BaseModel import BaseModel
|
||||
|
||||
|
||||
|
@ -80,9 +81,9 @@ class ClusterPrinterStatus(BaseModel):
|
|||
model.setCameraUrl(QUrl("http://{}:8080/?action=stream".format(self.ip_address)))
|
||||
|
||||
# Set the possible configurations based on whether a Material Station is present or not.
|
||||
if self.material_station is not None and len(self.material_station.material_slots):
|
||||
if self.material_station and self.material_station.material_slots:
|
||||
self._updateAvailableConfigurations(model)
|
||||
if self.configuration is not None:
|
||||
if self.configuration:
|
||||
self._updateActiveConfiguration(model)
|
||||
|
||||
def _updateActiveConfiguration(self, model: PrinterOutputModel) -> None:
|
||||
|
@ -92,31 +93,36 @@ class ClusterPrinterStatus(BaseModel):
|
|||
configuration.updateConfigurationModel(extruder_config)
|
||||
|
||||
def _updateAvailableConfigurations(self, model: PrinterOutputModel) -> None:
|
||||
# Generate a list of configurations for the left extruder.
|
||||
left_configurations = [slot for slot in self.material_station.material_slots if self._isSupportedConfiguration(
|
||||
slot = slot,
|
||||
extruder_index = 0
|
||||
)]
|
||||
# Generate a list of configurations for the right extruder.
|
||||
right_configurations = [slot for slot in self.material_station.material_slots if self._isSupportedConfiguration(
|
||||
slot = slot,
|
||||
extruder_index = 1
|
||||
)]
|
||||
# Create a list of all available combinations between both print cores.
|
||||
available_configurations = [self._createAvailableConfigurationFromPrinterConfiguration(
|
||||
left_slot = left_slot,
|
||||
right_slot = right_slot,
|
||||
printer_configuration = model.printerConfiguration
|
||||
) for left_slot, right_slot in product(left_configurations, right_configurations)]
|
||||
# Let Cura know which available configurations there are.
|
||||
) for left_slot, right_slot in product(self._getSlotsForExtruder(0), self._getSlotsForExtruder(1))]
|
||||
model.setAvailableConfigurations(available_configurations)
|
||||
|
||||
## Create a list of Material Station slots for the given extruder index.
|
||||
# Returns a list with a single empty material slot if none are found to ensure we don't miss configurations.
|
||||
def _getSlotsForExtruder(self, extruder_index: int) -> List[ClusterPrinterMaterialStationSlot]:
|
||||
if not self.material_station: # typing guard
|
||||
return []
|
||||
slots = [slot for slot in self.material_station.material_slots if self._isSupportedConfiguration(
|
||||
slot = slot,
|
||||
extruder_index = extruder_index
|
||||
)]
|
||||
return slots or [self._createEmptyMaterialSlot(extruder_index)]
|
||||
|
||||
## Check if a configuration is supported in order to make it selectable by the user.
|
||||
# We filter out any slot that is not supported by the extruder index, print core type or if the material is empty.
|
||||
@staticmethod
|
||||
def _isSupportedConfiguration(slot: ClusterPrinterMaterialStationSlot, extruder_index: int) -> bool:
|
||||
return slot.extruder_index == extruder_index and slot.compatible and slot.material and \
|
||||
slot.material_remaining != 0
|
||||
return slot.extruder_index == extruder_index and slot.compatible
|
||||
|
||||
## Create an empty material slot with a fake empty material.
|
||||
@staticmethod
|
||||
def _createEmptyMaterialSlot(extruder_index: int) -> ClusterPrinterMaterialStationSlot:
|
||||
empty_material = ClusterPrinterConfigurationMaterial(guid = "", material = "empty", brand = "", color = "")
|
||||
return ClusterPrinterMaterialStationSlot(slot_index = 0, extruder_index = extruder_index,
|
||||
compatible = True, material_remaining = 0, material = empty_material)
|
||||
|
||||
@staticmethod
|
||||
def _createAvailableConfigurationFromPrinterConfiguration(left_slot: ClusterPrinterMaterialStationSlot,
|
||||
|
|
0
plugins/UM3NetworkPrinting/src/Models/Http/__init__.py
Normal file
0
plugins/UM3NetworkPrinting/src/Models/Http/__init__.py
Normal file
Loading…
Add table
Add a link
Reference in a new issue