mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-22 13:49:39 +08:00
Added material conflict option
This is still desabled by default due to some architecture issues (so this is temporarily left as it is) CURA-1263
This commit is contained in:
parent
b59be4c88b
commit
b175e6876f
@ -65,6 +65,18 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||
machine_conflict = True
|
||||
break
|
||||
|
||||
material_conflict = False
|
||||
xml_material_profile = self._getXmlProfileClass()
|
||||
if self._material_container_suffix is None:
|
||||
self._material_container_suffix = ContainerRegistry.getMimeTypeForContainer(xml_material_profile).suffixes[0]
|
||||
if xml_material_profile:
|
||||
material_container_files = [name for name in cura_file_names if name.endswith(self._material_container_suffix)]
|
||||
for material_container_file in material_container_files:
|
||||
container_id = self._stripFileToId(material_container_file)
|
||||
materials = self._container_registry.findInstanceContainers(id=container_id)
|
||||
if materials and not materials[0].isReadOnly(): # Only non readonly materials can be in conflict
|
||||
material_conflict = True
|
||||
|
||||
# Check if any quality_changes instance container is in conflict.
|
||||
instance_container_files = [name for name in cura_file_names if name.endswith(self._instance_container_suffix)]
|
||||
for instance_container_file in instance_container_files:
|
||||
@ -83,10 +95,11 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||
quality_changes_conflict = True
|
||||
break
|
||||
|
||||
if machine_conflict or quality_changes_conflict:
|
||||
if machine_conflict or quality_changes_conflict or material_conflict:
|
||||
# There is a conflict; User should choose to either update the existing data, add everything as new data or abort
|
||||
self._dialog.setMachineConflict(machine_conflict)
|
||||
self._dialog.setQualityChangesConflict(quality_changes_conflict)
|
||||
self._dialog.setMaterialConflict(material_conflict)
|
||||
self._dialog.show()
|
||||
self._dialog.waitForClose()
|
||||
if self._dialog.getResult() == {}:
|
||||
@ -147,6 +160,10 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||
material_container = xml_material_profile(container_id)
|
||||
material_container.deserialize(archive.open(material_container_file).read().decode("utf-8"))
|
||||
self._container_registry.addContainer(material_container)
|
||||
else:
|
||||
if self._resolve_strategies["material"] == "override":
|
||||
pass
|
||||
|
||||
|
||||
Logger.log("d", "Workspace loading is checking instance containers...")
|
||||
# Get quality_changes and user profiles saved in the workspace
|
||||
@ -194,6 +211,9 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||
else:
|
||||
if self._resolve_strategies["quality_changes"] == "override":
|
||||
quality_changes[0].deserialize(archive.open(instance_container_file).read().decode("utf-8"))
|
||||
elif self._resolve_strategies["quality_changes"] is None:
|
||||
# The ID already exists, but nothing in the values changed, so do nothing.
|
||||
pass
|
||||
quality_changes_instance_containers.append(instance_container)
|
||||
else:
|
||||
continue
|
||||
|
@ -18,15 +18,19 @@ class WorkspaceDialog(QObject):
|
||||
self._qml_url = "WorkspaceDialog.qml"
|
||||
self._lock = threading.Lock()
|
||||
self._default_strategy = "override"
|
||||
self._result = {"machine": self._default_strategy, "quality_changes": self._default_strategy}
|
||||
self._result = {"machine": self._default_strategy,
|
||||
"quality_changes": self._default_strategy,
|
||||
"material": self._default_strategy}
|
||||
self._visible = False
|
||||
self.showDialogSignal.connect(self.__show)
|
||||
|
||||
self._has_quality_changes_conflict = False
|
||||
self._has_machine_conflict = False
|
||||
self._has_material_conflict = False
|
||||
|
||||
machineConflictChanged = pyqtSignal()
|
||||
qualityChangesConflictChanged = pyqtSignal()
|
||||
materialConflictChanged = pyqtSignal()
|
||||
|
||||
@pyqtProperty(bool, notify = machineConflictChanged)
|
||||
def machineConflict(self):
|
||||
@ -36,11 +40,19 @@ class WorkspaceDialog(QObject):
|
||||
def qualityChangesConflict(self):
|
||||
return self._has_quality_changes_conflict
|
||||
|
||||
@pyqtProperty(bool, notify=materialConflictChanged)
|
||||
def materialConflict(self):
|
||||
return self._has_material_conflict
|
||||
|
||||
@pyqtSlot(str, str)
|
||||
def setResolveStrategy(self, key, strategy):
|
||||
if key in self._result:
|
||||
self._result[key] = strategy
|
||||
|
||||
def setMaterialConflict(self, material_conflict):
|
||||
self._has_material_conflict = material_conflict
|
||||
self.materialConflictChanged.emit()
|
||||
|
||||
def setMachineConflict(self, machine_conflict):
|
||||
self._has_machine_conflict = machine_conflict
|
||||
self.machineConflictChanged.emit()
|
||||
@ -54,6 +66,8 @@ class WorkspaceDialog(QObject):
|
||||
self._result["machine"] = None
|
||||
if "quality_changes" in self._result and not self._has_quality_changes_conflict:
|
||||
self._result["quality_changes"] = None
|
||||
if "material" in self._result and not self._has_material_conflict:
|
||||
self._result["material"] = None
|
||||
return self._result
|
||||
|
||||
def _createViewFromQML(self):
|
||||
@ -63,14 +77,16 @@ class WorkspaceDialog(QObject):
|
||||
self._context.setContextProperty("manager", self)
|
||||
self._view = self._component.create(self._context)
|
||||
if self._view is None:
|
||||
Logger.log("e", "QQmlComponent status %s", self._component.status())
|
||||
Logger.log("e", "QQmlComponent errorString %s", self._component.errorString())
|
||||
Logger.log("c", "QQmlComponent status %s", self._component.status())
|
||||
Logger.log("c", "QQmlComponent error string %s", self._component.errorString())
|
||||
|
||||
def show(self):
|
||||
# Emit signal so the right thread actually shows the view.
|
||||
self._lock.acquire()
|
||||
# Reset the result
|
||||
self._result = {"machine": self._default_strategy, "quality_changes": self._default_strategy}
|
||||
self._result = {"machine": self._default_strategy,
|
||||
"quality_changes": self._default_strategy,
|
||||
"material": self._default_strategy}
|
||||
self._visible = True
|
||||
self.showDialogSignal.emit()
|
||||
|
||||
|
@ -27,6 +27,7 @@ UM.Dialog
|
||||
{
|
||||
machineResolveComboBox.currentIndex = 0
|
||||
qualityChangesResolveComboBox.currentIndex = 0
|
||||
materialConflictComboBox.currentIndex = 0
|
||||
}
|
||||
}
|
||||
Item
|
||||
@ -121,6 +122,35 @@ UM.Dialog
|
||||
}
|
||||
}
|
||||
}
|
||||
UM.TooltipArea
|
||||
{
|
||||
id: materialResolveTooltip
|
||||
width: parent.width
|
||||
height: visible ? 25 : 0
|
||||
text: catalog.i18nc("@info:tooltip", "How should the conflict in the material(s) be resolved?")
|
||||
visible: false #manager.materialConflict
|
||||
Row
|
||||
{
|
||||
width: parent.width
|
||||
height: childrenRect.height
|
||||
Label
|
||||
{
|
||||
text: catalog.i18nc("@action:label","Material")
|
||||
width: 150
|
||||
}
|
||||
|
||||
ComboBox
|
||||
{
|
||||
model: resolveStrategiesModel
|
||||
textRole: "label"
|
||||
id: materialResolveComboBox
|
||||
onActivated:
|
||||
{
|
||||
manager.setResolveStrategy("material", resolveStrategiesModel.get(index).key)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
rightButtons: [
|
||||
|
Loading…
x
Reference in New Issue
Block a user