mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
CURA-4870 Wait until the configuration has all the mandatory data before
add it to the list of unique configurations. Remove some connections to signals and reuse already defined listeners.
This commit is contained in:
parent
d807ce57a5
commit
dfb903fb81
6 changed files with 36 additions and 21 deletions
|
@ -40,6 +40,16 @@ class ConfigurationModel(QObject):
|
|||
def buildplateConfiguration(self):
|
||||
return self._buildplate_configuration
|
||||
|
||||
## This method is intended to indicate whether the configuration is valid or not.
|
||||
# The method checks if the mandatory fields are or not set
|
||||
def isValid(self):
|
||||
if not self._extruder_configurations:
|
||||
return False
|
||||
for configuration in self._extruder_configurations:
|
||||
if configuration is None:
|
||||
return False
|
||||
return self._printer_type is not None
|
||||
|
||||
def __str__(self):
|
||||
message_chunks = []
|
||||
message_chunks.append("Printer type: " + self._printer_type)
|
||||
|
|
|
@ -35,8 +35,13 @@ class ExtruderConfigurationModel(QObject):
|
|||
def hotendID(self):
|
||||
return self._hotend_id
|
||||
|
||||
## This method is intended to indicate whether the configuration is valid or not.
|
||||
# The method checks if the mandatory fields are or not set
|
||||
def isValid(self):
|
||||
return self._material is not None and self._hotend_id is not None and self.material.guid is not None
|
||||
|
||||
def __str__(self):
|
||||
if self._material is None or self._hotend_id is None or self.material.type is None:
|
||||
if not self.isValid():
|
||||
return "No information"
|
||||
return "Position: " + str(self._position) + " - Material: " + self._material.type + " - HotendID: " + self._hotend_id
|
||||
|
||||
|
|
|
@ -28,9 +28,7 @@ class ExtruderOutputModel(QObject):
|
|||
self._hotend_id = ""
|
||||
self._active_material = None # type: Optional[MaterialOutputModel]
|
||||
self._extruder_configuration = ExtruderConfigurationModel()
|
||||
# Update the configuration every time the hotend or the active material change
|
||||
self.hotendIDChanged.connect(self._updateExtruderConfiguration)
|
||||
self.activeMaterialChanged.connect(self._updateExtruderConfiguration)
|
||||
self._extruder_configuration.position = self._position
|
||||
|
||||
@pyqtProperty(QObject, notify = activeMaterialChanged)
|
||||
def activeMaterial(self) -> "MaterialOutputModel":
|
||||
|
@ -39,7 +37,9 @@ class ExtruderOutputModel(QObject):
|
|||
def updateActiveMaterial(self, material: Optional["MaterialOutputModel"]):
|
||||
if self._active_material != material:
|
||||
self._active_material = material
|
||||
self._extruder_configuration.material = self._active_material
|
||||
self.activeMaterialChanged.emit()
|
||||
self.extruderConfigurationChanged.emit()
|
||||
|
||||
## Update the hotend temperature. This only changes it locally.
|
||||
def updateHotendTemperature(self, temperature: float):
|
||||
|
@ -73,14 +73,12 @@ class ExtruderOutputModel(QObject):
|
|||
def updateHotendID(self, id: str):
|
||||
if self._hotend_id != id:
|
||||
self._hotend_id = id
|
||||
self._extruder_configuration.hotendID = self._hotend_id
|
||||
self.hotendIDChanged.emit()
|
||||
self.extruderConfigurationChanged.emit()
|
||||
|
||||
@pyqtProperty(QObject, notify = extruderConfigurationChanged)
|
||||
def extruderConfiguration(self):
|
||||
if self._extruder_configuration.isValid():
|
||||
return self._extruder_configuration
|
||||
|
||||
def _updateExtruderConfiguration(self):
|
||||
self._extruder_configuration.position = self._position
|
||||
self._extruder_configuration.material = self._active_material
|
||||
self._extruder_configuration.hotendID = self._hotend_id
|
||||
self.extruderConfigurationChanged.emit()
|
||||
return None
|
||||
|
|
|
@ -45,9 +45,7 @@ class PrinterOutputModel(QObject):
|
|||
self._buildplate_name = None
|
||||
# Update the printer configuration every time any of the extruders changes its configuration
|
||||
for extruder in self._extruders:
|
||||
extruder.extruderConfigurationChanged.connect(self._updatePrinterConfiguration)
|
||||
self.printerTypeChanged.connect(self._updatePrinterConfiguration)
|
||||
self.buildplateChanged.connect(self._updatePrinterConfiguration)
|
||||
extruder.extruderConfigurationChanged.connect(self._updateExtruderConfiguration)
|
||||
|
||||
self._camera = None
|
||||
|
||||
|
@ -80,16 +78,20 @@ class PrinterOutputModel(QObject):
|
|||
def updateType(self, printer_type):
|
||||
if self._printer_type != printer_type:
|
||||
self._printer_type = printer_type
|
||||
self._printer_configuration.printerType = self._printer_type
|
||||
self.printerTypeChanged.emit()
|
||||
self.configurationChanged.emit()
|
||||
|
||||
@pyqtProperty(str, notify = buildplateChanged)
|
||||
def buildplate(self):
|
||||
return self._buildplate_name
|
||||
|
||||
def updateBuildplate(self, buildplate_name):
|
||||
def updateBuildplateName(self, buildplate_name):
|
||||
if self._buildplate_name != buildplate_name:
|
||||
self._buildplate_name = buildplate_name
|
||||
self._printer_configuration.buildplateConfiguration = self._buildplate_name
|
||||
self.buildplateChanged.emit()
|
||||
self.configurationChanged.emit()
|
||||
|
||||
@pyqtProperty(str, notify=keyChanged)
|
||||
def key(self):
|
||||
|
@ -260,10 +262,10 @@ class PrinterOutputModel(QObject):
|
|||
# Returns the configuration (material, variant and buildplate) of the current printer
|
||||
@pyqtProperty(QObject, notify = configurationChanged)
|
||||
def printerConfiguration(self):
|
||||
if self._printer_configuration.isValid():
|
||||
return self._printer_configuration
|
||||
return None
|
||||
|
||||
def _updatePrinterConfiguration(self):
|
||||
self._printer_configuration.printerType = self._printer_type
|
||||
def _updateExtruderConfiguration(self):
|
||||
self._printer_configuration.extruderConfigurations = [extruder.extruderConfiguration for extruder in self._extruders]
|
||||
self._printer_configuration.buildplateConfiguration = self._buildplate_name
|
||||
self.configurationChanged.emit()
|
||||
|
|
|
@ -187,7 +187,7 @@ class PrinterOutputDevice(QObject, OutputDevice):
|
|||
return self._unique_configurations
|
||||
|
||||
def _updateUniqueConfigurations(self):
|
||||
self._unique_configurations = list(set([printer.printerConfiguration for printer in self._printers]))
|
||||
self._unique_configurations = list(set([printer.printerConfiguration for printer in self._printers if printer.printerConfiguration is not None]))
|
||||
self._unique_configurations.sort(key = lambda k: k.printerType)
|
||||
self.uniqueConfigurationsChanged.emit()
|
||||
|
||||
|
|
|
@ -384,7 +384,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
|
|||
|
||||
# Do not store the buildplate information that comes from connect if the current printer has not buildplate information
|
||||
if "build_plate" in data and machine_definition.getMetaDataEntry("has_variant_buildplates", False):
|
||||
printer.updateBuildplate(data["build_plate"]["type"])
|
||||
printer.updateBuildplateName(data["build_plate"]["type"])
|
||||
if not data["enabled"]:
|
||||
printer.updateState("disabled")
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue