mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
CURA-4870 Fix an error in the hash function that detects a matching when
the extruders are inverted. Add pretty output to the configuration model.
This commit is contained in:
parent
51686943e6
commit
d83eb383d9
3 changed files with 20 additions and 6 deletions
|
@ -40,11 +40,19 @@ class ConfigurationModel(QObject):
|
||||||
def buildplateConfiguration(self):
|
def buildplateConfiguration(self):
|
||||||
return self._buildplate_configuration
|
return self._buildplate_configuration
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
info = "Printer type: " + self.printerType + "\n"
|
||||||
|
info += "Extruders: [\n"
|
||||||
|
for configuration in self.extruderConfigurations:
|
||||||
|
info += " " + str(configuration) + "\n"
|
||||||
|
info += "]"
|
||||||
|
return info
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return hash(self) == hash(other)
|
return hash(self) == hash(other)
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
extruder_hash = hash(0)
|
extruder_hash = hash(self.extruderConfigurations[0]) # Use the hash of the first extruder as a seed
|
||||||
for configuration in self.extruderConfigurations:
|
for configuration in self.extruderConfigurations:
|
||||||
extruder_hash ^= configuration.__hash__()
|
extruder_hash ^= hash(configuration)
|
||||||
return hash(self.printerType) ^ extruder_hash ^ hash(self.buildplateConfiguration)
|
return hash(self._printer_type) ^ extruder_hash ^ hash(self._buildplate_configuration)
|
|
@ -35,8 +35,13 @@ class ExtruderConfigurationModel(QObject):
|
||||||
def hotendID(self):
|
def hotendID(self):
|
||||||
return self._hotend_id
|
return self._hotend_id
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
if self._material is None or self._hotend_id is None:
|
||||||
|
return "No information"
|
||||||
|
return "Position: " + str(self._position) + " - Material: " + self._material + " - HotendID: " + self._hotend_id
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return hash(self) == hash(other)
|
return hash(self) == hash(other)
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
return hash(self.position) ^ hash(self.material) ^ hash(self.hotendID)
|
return hash(self._position) ^ hash(self._material) ^ hash(self._hotend_id)
|
|
@ -191,8 +191,9 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
@pyqtSlot(QObject, result = bool)
|
@pyqtSlot(QObject, result = bool)
|
||||||
def matchesConfiguration(self, configuration: ConfigurationModel) -> bool:
|
def matchesConfiguration(self, configuration: ConfigurationModel) -> bool:
|
||||||
# print("@@@@@@@@@@@@@@@@@@", configuration.extruderConfigurations)
|
# print(configuration)
|
||||||
# print("##################", self._current_printer_configuration.extruderConfigurations, configuration == self._current_printer_configuration)
|
# print(self._current_printer_configuration)
|
||||||
|
# print("%%%%%%%%", configuration == self._current_printer_configuration)
|
||||||
return self._current_printer_configuration == configuration
|
return self._current_printer_configuration == configuration
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue