mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 14:44:13 -06:00
CURA-4870 Style the __str__ function
This commit is contained in:
parent
54882402ad
commit
b3f9679a5f
2 changed files with 12 additions and 7 deletions
|
@ -41,18 +41,22 @@ class ConfigurationModel(QObject):
|
||||||
return self._buildplate_configuration
|
return self._buildplate_configuration
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
info = "Printer type: " + self._printer_type + "\n"
|
message_chunks = []
|
||||||
info += "Extruders: [\n"
|
message_chunks.append("Printer type: " + self._printer_type)
|
||||||
|
message_chunks.append("Extruders: [")
|
||||||
for configuration in self._extruder_configurations:
|
for configuration in self._extruder_configurations:
|
||||||
info += " " + str(configuration) + "\n"
|
message_chunks.append(" " + str(configuration))
|
||||||
info += "]"
|
message_chunks.append("]")
|
||||||
if self._buildplate_configuration is not None:
|
if self._buildplate_configuration is not None:
|
||||||
info += "\nBuildplate: " + self._buildplate_configuration
|
message_chunks.append("Buildplate: " + self._buildplate_configuration)
|
||||||
return info
|
|
||||||
|
return "\n".join(message_chunks)
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return hash(self) == hash(other)
|
return hash(self) == hash(other)
|
||||||
|
|
||||||
|
## The hash function is used to compare and create unique sets. The configuration is unique if the configuration
|
||||||
|
# of the extruders is unique (the order of the extruders matters), and the type and buildplate is the same.
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
extruder_hash = hash(0)
|
extruder_hash = hash(0)
|
||||||
first_extruder = None
|
first_extruder = None
|
||||||
|
@ -60,6 +64,7 @@ class ConfigurationModel(QObject):
|
||||||
extruder_hash ^= hash(configuration)
|
extruder_hash ^= hash(configuration)
|
||||||
if configuration.position == 0:
|
if configuration.position == 0:
|
||||||
first_extruder = configuration
|
first_extruder = configuration
|
||||||
|
# To ensure the correct order of the extruders, we add an "and" operation using the first extruder hash value
|
||||||
if first_extruder:
|
if first_extruder:
|
||||||
extruder_hash &= hash(first_extruder)
|
extruder_hash &= hash(first_extruder)
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ class ExtruderOutputModel(QObject):
|
||||||
def targetHotendTemperature(self) -> float:
|
def targetHotendTemperature(self) -> float:
|
||||||
return self._target_hotend_temperature
|
return self._target_hotend_temperature
|
||||||
|
|
||||||
@pyqtProperty(float, notify=hotendTemperatureChanged)
|
@pyqtProperty(float, notify = hotendTemperatureChanged)
|
||||||
def hotendTemperature(self) -> float:
|
def hotendTemperature(self) -> float:
|
||||||
return self._hotend_temperature
|
return self._hotend_temperature
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue