mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-17 06:35:58 +08:00
Merge branch 'master' of github.com:Ultimaker/Cura
This commit is contained in:
commit
a9efa3e612
@ -111,7 +111,7 @@ class CuraApplication(QtApplication):
|
|||||||
self._i18n_catalog = None
|
self._i18n_catalog = None
|
||||||
self._previous_active_tool = None
|
self._previous_active_tool = None
|
||||||
self._platform_activity = False
|
self._platform_activity = False
|
||||||
self._scene_boundingbox = AxisAlignedBox()
|
self._scene_bounding_box = AxisAlignedBox()
|
||||||
self._job_name = None
|
self._job_name = None
|
||||||
self._center_after_select = False
|
self._center_after_select = False
|
||||||
self._camera_animation = None
|
self._camera_animation = None
|
||||||
@ -389,26 +389,26 @@ class CuraApplication(QtApplication):
|
|||||||
|
|
||||||
@pyqtProperty(str, notify = sceneBoundingBoxChanged)
|
@pyqtProperty(str, notify = sceneBoundingBoxChanged)
|
||||||
def getSceneBoundingBoxString(self):
|
def getSceneBoundingBoxString(self):
|
||||||
return self._i18n_catalog.i18nc("@info", "%(width).1f x %(depth).1f x %(height).1f mm") % {'width' : self._scene_boundingbox.width.item(), 'depth': self._scene_boundingbox.depth.item(), 'height' : self._scene_boundingbox.height.item()}
|
return self._i18n_catalog.i18nc("@info", "%(width).1f x %(depth).1f x %(height).1f mm") % {'width' : self._scene_bounding_box.width.item(), 'depth': self._scene_bounding_box.depth.item(), 'height' : self._scene_bounding_box.height.item()}
|
||||||
|
|
||||||
def updatePlatformActivity(self, node = None):
|
def updatePlatformActivity(self, node = None):
|
||||||
count = 0
|
count = 0
|
||||||
scene_boundingbox = None
|
scene_bounding_box = None
|
||||||
for node in DepthFirstIterator(self.getController().getScene().getRoot()):
|
for node in DepthFirstIterator(self.getController().getScene().getRoot()):
|
||||||
if type(node) is not SceneNode or not node.getMeshData():
|
if type(node) is not SceneNode or not node.getMeshData():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
count += 1
|
count += 1
|
||||||
if not scene_boundingbox:
|
if not scene_bounding_box:
|
||||||
scene_boundingbox = copy.deepcopy(node.getBoundingBox())
|
scene_bounding_box = copy.deepcopy(node.getBoundingBox())
|
||||||
else:
|
else:
|
||||||
scene_boundingbox += node.getBoundingBox()
|
scene_bounding_box += node.getBoundingBox()
|
||||||
|
|
||||||
if not scene_boundingbox:
|
if not scene_bounding_box:
|
||||||
scene_boundingbox = AxisAlignedBox()
|
scene_bounding_box = AxisAlignedBox()
|
||||||
|
|
||||||
if repr(self._scene_boundingbox) != repr(scene_boundingbox):
|
if repr(self._scene_bounding_box) != repr(scene_bounding_box):
|
||||||
self._scene_boundingbox = scene_boundingbox
|
self._scene_bounding_box = scene_bounding_box
|
||||||
self.sceneBoundingBoxChanged.emit()
|
self.sceneBoundingBoxChanged.emit()
|
||||||
|
|
||||||
self._platform_activity = True if count > 0 else False
|
self._platform_activity = True if count > 0 else False
|
||||||
|
@ -5,6 +5,8 @@ from UM.Preferences import Preferences
|
|||||||
|
|
||||||
import UM.Settings
|
import UM.Settings
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
class MachineManagerModel(QObject):
|
class MachineManagerModel(QObject):
|
||||||
def __init__(self, parent = None):
|
def __init__(self, parent = None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
@ -64,6 +66,7 @@ class MachineManagerModel(QObject):
|
|||||||
definitions = UM.Settings.ContainerRegistry.getInstance().findDefinitionContainers(id=definition_id)
|
definitions = UM.Settings.ContainerRegistry.getInstance().findDefinitionContainers(id=definition_id)
|
||||||
if definitions:
|
if definitions:
|
||||||
definition = definitions[0]
|
definition = definitions[0]
|
||||||
|
name = self._uniqueMachineName(name, definition.getName())
|
||||||
|
|
||||||
new_global_stack = UM.Settings.ContainerStack(name)
|
new_global_stack = UM.Settings.ContainerStack(name)
|
||||||
new_global_stack.addMetaDataEntry("type", "machine")
|
new_global_stack.addMetaDataEntry("type", "machine")
|
||||||
@ -127,6 +130,25 @@ class MachineManagerModel(QObject):
|
|||||||
|
|
||||||
Application.getInstance().setGlobalContainerStack(new_global_stack)
|
Application.getInstance().setGlobalContainerStack(new_global_stack)
|
||||||
|
|
||||||
|
# Create a name that is not empty and unique
|
||||||
|
def _uniqueMachineName(self, name, fallback_name):
|
||||||
|
name = name.strip()
|
||||||
|
num_check = re.compile("(.*?)\s*#\d$").match(name)
|
||||||
|
if(num_check):
|
||||||
|
name = num_check.group(1)
|
||||||
|
if name == "":
|
||||||
|
name = fallback_name
|
||||||
|
unique_name = name
|
||||||
|
i = 1
|
||||||
|
|
||||||
|
#Check both the id and the name, because they may not be the same and it is better if they are both unique
|
||||||
|
while UM.Settings.ContainerRegistry.getInstance().findContainers(None, id = unique_name) or \
|
||||||
|
UM.Settings.ContainerRegistry.getInstance().findContainers(None, name = unique_name):
|
||||||
|
i = i + 1
|
||||||
|
unique_name = "%s #%d" % (name, i)
|
||||||
|
|
||||||
|
return unique_name
|
||||||
|
|
||||||
@pyqtProperty(str, notify = globalContainerChanged)
|
@pyqtProperty(str, notify = globalContainerChanged)
|
||||||
def activeMachineName(self):
|
def activeMachineName(self):
|
||||||
if self._global_container_stack:
|
if self._global_container_stack:
|
||||||
@ -239,6 +261,7 @@ class MachineManagerModel(QObject):
|
|||||||
def renameMachine(self, machine_id, new_name):
|
def renameMachine(self, machine_id, new_name):
|
||||||
containers = UM.Settings.ContainerRegistry.getInstance().findContainerStacks(id = machine_id)
|
containers = UM.Settings.ContainerRegistry.getInstance().findContainerStacks(id = machine_id)
|
||||||
if containers:
|
if containers:
|
||||||
|
new_name = self._uniqueMachineName(new_name, containers[0].getBottom().getName())
|
||||||
containers[0].setName(new_name)
|
containers[0].setName(new_name)
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
|
@ -134,26 +134,26 @@ class CuraEngineBackend(Backend):
|
|||||||
self._process_layers_job.abort()
|
self._process_layers_job.abort()
|
||||||
self._process_layers_job = None
|
self._process_layers_job = None
|
||||||
|
|
||||||
#Don't slice if there is a setting with an error value.
|
# #Don't slice if there is a setting with an error value.
|
||||||
stack = Application.getInstance().getGlobalContainerStack()
|
# stack = Application.getInstance().getGlobalContainerStack()
|
||||||
for key in stack.getAllKeys():
|
# for key in stack.getAllKeys():
|
||||||
validation_state = stack.getProperty(key, "validationState")
|
# validation_state = stack.getProperty(key, "validationState")
|
||||||
#Only setting instances have a validation state, so settings which
|
# #Only setting instances have a validation state, so settings which
|
||||||
#are not overwritten by any instance will have none. The property
|
# #are not overwritten by any instance will have none. The property
|
||||||
#then, and only then, evaluates to None. We make the assumption that
|
# #then, and only then, evaluates to None. We make the assumption that
|
||||||
#the definition defines the setting with a default value that is
|
# #the definition defines the setting with a default value that is
|
||||||
#valid. Therefore we can allow both ValidatorState.Valid and None as
|
# #valid. Therefore we can allow both ValidatorState.Valid and None as
|
||||||
#allowable validation states.
|
# #allowable validation states.
|
||||||
#TODO: This assumption is wrong! If the definition defines an inheritance function that through inheritance evaluates to a disallowed value, a setting is still invalid even though it's default!
|
# #TODO: This assumption is wrong! If the definition defines an inheritance function that through inheritance evaluates to a disallowed value, a setting is still invalid even though it's default!
|
||||||
#TODO: Therefore we must also validate setting definitions.
|
# #TODO: Therefore we must also validate setting definitions.
|
||||||
if validation_state != None and validation_state != ValidatorState.Valid:
|
# if validation_state != None and validation_state != ValidatorState.Valid:
|
||||||
Logger.log("w", "Setting %s is not valid, but %s. Aborting slicing.", key, validation_state)
|
# Logger.log("w", "Setting %s is not valid, but %s. Aborting slicing.", key, validation_state)
|
||||||
if self._message: #Hide any old message before creating a new one.
|
# if self._message: #Hide any old message before creating a new one.
|
||||||
self._message.hide()
|
# self._message.hide()
|
||||||
self._message = None
|
# self._message = None
|
||||||
self._message = Message(catalog.i18nc("@info:status", "Unable to slice. Please check your setting values for errors."))
|
# self._message = Message(catalog.i18nc("@info:status", "Unable to slice. Please check your setting values for errors."))
|
||||||
self._message.show()
|
# self._message.show()
|
||||||
return
|
# return
|
||||||
|
|
||||||
self.processingProgress.emit(0.0)
|
self.processingProgress.emit(0.0)
|
||||||
self.backendStateChange.emit(BackendState.NOT_STARTED)
|
self.backendStateChange.emit(BackendState.NOT_STARTED)
|
||||||
@ -168,7 +168,7 @@ class CuraEngineBackend(Backend):
|
|||||||
self.slicingStarted.emit()
|
self.slicingStarted.emit()
|
||||||
|
|
||||||
slice_message = self._socket.createMessage("cura.proto.Slice")
|
slice_message = self._socket.createMessage("cura.proto.Slice")
|
||||||
settings_message = self._socket.createMessage("cura.proto.SettingList");
|
settings_message = self._socket.createMessage("cura.proto.SettingList")
|
||||||
self._start_slice_job = StartSliceJob.StartSliceJob(slice_message, settings_message)
|
self._start_slice_job = StartSliceJob.StartSliceJob(slice_message, settings_message)
|
||||||
self._start_slice_job.start()
|
self._start_slice_job.start()
|
||||||
self._start_slice_job.finished.connect(self._onStartSliceCompleted)
|
self._start_slice_job.finished.connect(self._onStartSliceCompleted)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user