mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 15:07:28 -06:00
Bit of code refactoring to prevent duplication
CURA-1288
This commit is contained in:
parent
184247ced6
commit
95a0c69662
1 changed files with 20 additions and 18 deletions
|
@ -51,6 +51,20 @@ class StartSliceJob(Job):
|
||||||
def getSliceMessage(self):
|
def getSliceMessage(self):
|
||||||
return self._slice_message
|
return self._slice_message
|
||||||
|
|
||||||
|
## Check if a stack has any errors.
|
||||||
|
## returns true if it has errors, false otherwise.
|
||||||
|
def _checkStackForErrors(self, stack):
|
||||||
|
if stack is None:
|
||||||
|
return False
|
||||||
|
|
||||||
|
for key in stack.getAllKeys():
|
||||||
|
validation_state = stack.getProperty(key, "validationState")
|
||||||
|
if validation_state in (ValidatorState.Exception, ValidatorState.MaximumError, ValidatorState.MinimumError):
|
||||||
|
Logger.log("w", "Setting %s is not valid, but %s. Aborting slicing.", key, validation_state)
|
||||||
|
return True
|
||||||
|
Job.yieldThread()
|
||||||
|
return False
|
||||||
|
|
||||||
## Runs the job that initiates the slicing.
|
## Runs the job that initiates the slicing.
|
||||||
def run(self):
|
def run(self):
|
||||||
stack = Application.getInstance().getGlobalContainerStack()
|
stack = Application.getInstance().getGlobalContainerStack()
|
||||||
|
@ -59,30 +73,18 @@ class StartSliceJob(Job):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Don't slice if there is a setting with an error value.
|
# Don't slice if there is a setting with an error value.
|
||||||
for key in stack.getAllKeys():
|
if self._checkStackForErrors(stack):
|
||||||
validation_state = stack.getProperty(key, "validationState")
|
self.setResult(StartJobResult.SettingError)
|
||||||
if validation_state in (ValidatorState.Exception, ValidatorState.MaximumError, ValidatorState.MinimumError):
|
return
|
||||||
Logger.log("w", "Setting %s is not valid, but %s. Aborting slicing.", key, validation_state)
|
|
||||||
self.setResult(StartJobResult.SettingError)
|
|
||||||
return
|
|
||||||
|
|
||||||
Job.yieldThread()
|
|
||||||
|
|
||||||
# Don't slice if there is a per object setting with an error value.
|
# Don't slice if there is a per object setting with an error value.
|
||||||
for node in DepthFirstIterator(self._scene.getRoot()):
|
for node in DepthFirstIterator(self._scene.getRoot()):
|
||||||
if type(node) is not SceneNode or not node.isSelectable():
|
if type(node) is not SceneNode or not node.isSelectable():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
node_stack = node.callDecoration("getStack")
|
if self._checkStackForErrors(node.callDecoration("getStack")):
|
||||||
if node_stack:
|
self.setResult(StartJobResult.SettingError)
|
||||||
for key in node_stack.getAllKeys():
|
return
|
||||||
validation_state = node_stack.getProperty(key, "validationState")
|
|
||||||
if validation_state in (ValidatorState.Exception, ValidatorState.MaximumError, ValidatorState.MinimumError):
|
|
||||||
Logger.log("w", "Per object setting %s is not valid, but %s. Aborting slicing.", key, validation_state)
|
|
||||||
self.setResult(StartJobResult.SettingError)
|
|
||||||
return
|
|
||||||
|
|
||||||
Job.yieldThread()
|
|
||||||
|
|
||||||
with self._scene.getSceneLock():
|
with self._scene.getSceneLock():
|
||||||
# Remove old layer data.
|
# Remove old layer data.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue