diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index b8656565a8..4d3d2434ff 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -307,7 +307,8 @@ class CuraApplication(QtApplication): super().initialize() self.__sendCommandToSingleInstance() - self._initializeSettingDefinitionsAndFunctions() + self._initializeSettingDefinitions() + self._initializeSettingFunctions() self.__addAllResourcesAndContainerResources() self.__addAllEmptyContainers() self.__setLatestResouceVersionsForVersionUpgrade() @@ -336,31 +337,40 @@ class CuraApplication(QtApplication): resource_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "resources") Resources.addSearchPath(resource_path) - # Adds custom property types, settings types, and extra operators (functions) that need to be registered in - # SettingDefinition and SettingFunction. - def _initializeSettingDefinitionsAndFunctions(self): - self._cura_formula_functions = CuraFormulaFunctions(self) - + @classmethod + def _initializeSettingDefinitions(cls): # Need to do this before ContainerRegistry tries to load the machines - SettingDefinition.addSupportedProperty("settable_per_mesh", DefinitionPropertyType.Any, default = True, read_only = True) - SettingDefinition.addSupportedProperty("settable_per_extruder", DefinitionPropertyType.Any, default = True, read_only = True) + SettingDefinition.addSupportedProperty("settable_per_mesh", DefinitionPropertyType.Any, default=True, + read_only=True) + SettingDefinition.addSupportedProperty("settable_per_extruder", DefinitionPropertyType.Any, default=True, + read_only=True) # this setting can be changed for each group in one-at-a-time mode - SettingDefinition.addSupportedProperty("settable_per_meshgroup", DefinitionPropertyType.Any, default = True, read_only = True) - SettingDefinition.addSupportedProperty("settable_globally", DefinitionPropertyType.Any, default = True, read_only = True) + SettingDefinition.addSupportedProperty("settable_per_meshgroup", DefinitionPropertyType.Any, default=True, + read_only=True) + SettingDefinition.addSupportedProperty("settable_globally", DefinitionPropertyType.Any, default=True, + read_only=True) # From which stack the setting would inherit if not defined per object (handled in the engine) # AND for settings which are not settable_per_mesh: # which extruder is the only extruder this setting is obtained from - SettingDefinition.addSupportedProperty("limit_to_extruder", DefinitionPropertyType.Function, default = "-1", depends_on = "value") + SettingDefinition.addSupportedProperty("limit_to_extruder", DefinitionPropertyType.Function, default="-1", + depends_on="value") # For settings which are not settable_per_mesh and not settable_per_extruder: # A function which determines the glabel/meshgroup value by looking at the values of the setting in all (used) extruders - SettingDefinition.addSupportedProperty("resolve", DefinitionPropertyType.Function, default = None, depends_on = "value") + SettingDefinition.addSupportedProperty("resolve", DefinitionPropertyType.Function, default=None, + depends_on="value") SettingDefinition.addSettingType("extruder", None, str, Validator) SettingDefinition.addSettingType("optional_extruder", None, str, None) SettingDefinition.addSettingType("[int]", None, str, None) + + # Adds custom property types, settings types, and extra operators (functions) that need to be registered in + # SettingDefinition and SettingFunction. + def _initializeSettingFunctions(self): + self._cura_formula_functions = CuraFormulaFunctions(self) + SettingFunction.registerOperator("extruderValue", self._cura_formula_functions.getValueInExtruder) SettingFunction.registerOperator("extruderValues", self._cura_formula_functions.getValuesInAllExtruders) SettingFunction.registerOperator("resolveOrValue", self._cura_formula_functions.getResolveOrValue) diff --git a/tests/Settings/TestProfiles.py b/tests/Settings/TestProfiles.py index cea797bd1c..f0fea06a4f 100644 --- a/tests/Settings/TestProfiles.py +++ b/tests/Settings/TestProfiles.py @@ -33,8 +33,7 @@ def collecAllDefinitionIds(): def collectAllSettingIds(): VersionUpgradeManager._VersionUpgradeManager__instance = VersionUpgradeManager(MagicMock()) - application = CuraApplication() - application._initializeSettingDefinitionsAndFunctions() + CuraApplication._initializeSettingDefinitions() definition_container = DefinitionContainer("whatever") with open(os.path.join(os.path.dirname(__file__), "..", "..", "resources", "definitions", "fdmprinter.def.json"), encoding="utf-8") as data: